Re: solution 4C#
Posted by
dzhob 13 Mar 2008 12:32
using System;
namespace _1020
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
string s = Console.ReadLine();
s = s.Replace('.',',');
string[] w = s.Split(' ');
int n = int.Parse(w[0]);
double r = double.Parse(w[1]);
double[,] k = new double[n,2];
for(int i = 0; i < n; i++)
{
string s1 = Console.ReadLine();
s1 = s1.Replace('.',',');
string[] w1 = s1.Split(' ');
k[i,0] = double.Parse(w1[0]);
k[i,1] = double.Parse(w1[1]);
}
double sum = 0;
for(int i = 0; i < n - 1; i++)
sum += Math.Sqrt((k[i,0] - k[i + 1,0])*(k[i,0] - k[i + 1,0]) + (k[i,1] - k[i + 1,1])*(k[i,1] - k[i + 1,1]));
sum += Math.Sqrt((k[0,0] - k[n - 1,0])*(k[0,0] - k[n - 1,0]) + (k[0,1] - k[n - 1,1])*(k[0,1] - k[n - 1,1]));
sum += 2*Math.PI*r;
sum += 0.005;
string h = sum.ToString();
h = h.Replace(',','.');
int x = h.IndexOf('.');
h = h.Insert(x+3, "r");
string[] v = h.Split('r');
Console.WriteLine(v[0]);
}
}
}