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

Please help... Wrong Answer on Test # 2 - C#
Posted by Alaska . PK 11 Apr 2011 03:50
NumberFormatInfo nfi = NumberFormatInfo.InvariantInfo;
            string nailsNradius = Console.ReadLine();
            string[] NailsNradius = nailsNradius.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            int nails = Int32.Parse(NailsNradius[0]);
            int radius = Int32.Parse(NailsNradius[1]);
            double length=0;
            string temp;

            for (int i = 0; i < nails; i++)
            {
                string tempInput = Console.ReadLine();
                string[] coordinates = tempInput.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

//calculating the sum (here length is sum)
                length += Double.Parse(coordinates[0]) + Double.Parse(coordinates[1]);
//converting it to two digits precision
                temp = string.Format(nfi, "{0:F2}",length.ToString());
                length = Double.Parse(temp);
            }
//finally printing the length + 2*PI*r with 2 digit precision
            Console.WriteLine(string.Format(nfi, "{0:F2}", length+(2*Math.PI*radius)));