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 1001. Reverse Root

What's wrong here ?
Posted by Black^n^White 8 Jan 2007 13:20
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 ?
Posted by Black^n^White 8 Jan 2007 14:33
oops. Stupid mistake - Split(' ') is not enought ...
I got AC !
Re: What's wrong here ?
Posted by xenium9 6 Jun 2008 20:06
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 ?
Posted by Zdravko Beykov 2 Jul 2008 23:32
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?