|
|
back to boardDiscussion of Problem 1020. RopePlease help... Wrong Answer on Test # 2 - C# 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))); |
|
|