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 in this? (C#)
Posted by gholamali 5 Feb 2014 22:54
using System;
namespace ConsoleApplication4
{
    class Program
    {
        static void SQRT(UInt64 sum)
        {
            double ima_ans = Convert.ToDouble(Math.Sqrt(Convert.ToDouble(sum)));
            Console.WriteLine(Convert.ToDouble((Math.Round(ima_ans = ima_ans * 10000)) / 10000));
        }
        static void Main(string[] args)
        {
            string save_str=null;
            string str = Console.ReadLine();
            int i = str.Length;
            int  k;
            UInt64 sum;
            i = i - 1;
            while (i >= 0)
            {
                k = 0;
                while (i >= 0 && str[i] != ' ')
                {
                    k = 1;
                    save_str += str[i];
                    i = i - 1;
                }
                sum = Convert.ToUInt64(save_str);
                if (sum > 0 && sum <= Math.Pow(10, 18) || k == 1)
                    SQRT(sum);
                save_str = null;
                i = i - 1;
            }
            Console.ReadLine();
        }
    }
}