|
|
вернуться в форумWhat's wrong here ? WA on test #2 ?!?? C# code: using System; using System.Text; class Program { static void Main() { System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; string[] nums = Console.In.ReadToEnd().Split(' '); for (int i = nums.Length - 1; i >= 0; --i) try { Console.WriteLine("{0:F4}", Math.Sqrt(ulong.Parse(nums[i]))); } catch (Exception) { /* Do nothing if nums[i] is not a number */ } } } Edited by author 08.01.2007 13:21 Re: What's wrong here ? oops. Stupid mistake - Split(' ') is not enought ... I got AC ! Re: What's wrong here ? using System; using System.Threading; using System.Globalization; using System.Text.RegularExpressions; class Program { static void Main() { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; string[] nums = Regex.Split(Console.In.ReadToEnd().Trim(), @"\s+"); for (int i = nums.Length - 1; i >= 0; i--) Console.WriteLine("{0:F4}", Math.Sqrt(ulong.Parse(nums[i]))); } } above is ACCEPTED, but why Wrong answer in Test#1 if miss: Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Re: What's wrong here ? using System; using System.Collections; public class Phone { public static void Main(string[] args) { System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; string input; ArrayList al = new ArrayList();
while((input=Console.ReadLine())!=null) { string[] d=input.Split(new string[]{" ","\t"},StringSplitOptions.RemoveEmptyEntries); foreach(string t in d) { if(t!="") { al.Add(double.Parse(t)); }
} } for(int i=al.Count-1;i>=0;i--) { Console.WriteLine("{0:f4}",Math.Sqrt((double)al[i])); } }
} Same here, if I miss the thread line, it gives WA #1, otherwise is OK. Why? What does it do? |
|
|