ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1020. Rope

solution 4C#
Posted by dzhob 13 Mar 2008 12:15


Edited by author 13.03.2008 12:29
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]);
        }
    }
}
Re: solution 4C#
Posted by Дмитрий 17 Aug 2008 21:56
"sum += 0.005;"
???????
Re: solution 4C#
Posted by Дмитрий 17 Aug 2008 21:59
:). I got it ))))