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

Why wrong answer C#
Posted by Md. Hasib Hasan Tarafder 19 Aug 2014 21:24
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ReverseRoot
{
    class Program
    {
        static void Main(string[] args)
        {
            string line;
            string input = "";
            double sqrt;
            while (!String.IsNullOrWhiteSpace(line = Console.ReadLine()))
            {
                input += " ";
                input += line;//but here it seems to be an infinite loop
            }

            if (Encoding.UTF8.GetBytes(input).Length / 1024 > 256)
            {
                Console.WriteLine("Sorry! Long Input Stream");
            }
            else
            {
                string[] arr = input.Split(' ');
                for (int i = arr.Length - 1; i >= 0; i--)
                {
                    if (!String.IsNullOrWhiteSpace(arr[i]))
                    {
                        sqrt = Math.Sqrt(Int64.Parse(arr[i]));
                        if (sqrt == 0)
                            Console.WriteLine(sqrt.ToString("0.0000"));
                        else
                            Console.WriteLine(sqrt.ToString("#.####"));
                    }
                }
            }
        }
    }
}