|
|
back to boardDiscussion of Problem 1020. RopePlease, help realize mistake in C# code. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; using System.Globalization; namespace _1020_thread{ class pt{ double x, y; public pt(double _x, double _y) { x = _x; y = _y; } public static pt operator- (pt p1, pt p2) { return new pt(p1.x - p2.x, p1.y - p2.y); } public static pt operator+ (pt p1, pt p2) { return new pt(p1.x + p2.x, p1.y + p2.y); } public double len() { return Math.Sqrt(x * x + y * y); } } class Program{ int n; double r, ans; List<pt> a; void Read(){ string[] s = Console.ReadLine().Split(); a = new List<pt>(); n = int.Parse(s[0]); r = double.Parse(s[1]); for (int i = 0; i < n; ++i) { s = Console.ReadLine().Split(); a.Add(new pt(double.Parse(s[0]), double.Parse(s[1]))); } } int next(List<pt> a, int i) { return (i + 1) % a.Count; } void Solve() { for (int i = 0; i < a.Count; ++i) ans += (a[i] - a[next(a, i)]).len(); ans += Math.PI * 2 * r; } void Print() { NumberFormatInfo nfi = NumberFormatInfo.InvariantInfo; Console.WriteLine(string.Format(nfi, "{0:F2}", ans)); } static void Main(string[] args){ //System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; Program p = new Program(); p.Read(); p.Solve(); p.Print(); } } } I have solve this problem using C++ without any problems. This code correct solve sample in statement and I can't find any mistakes in it, but it catch WA 1. Edited by author 24.10.2012 13:42 |
|
|