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 I get a runtime error (C#)
Posted by Stepan 21 Feb 2020 00:39
List<long> coll = new List<long>();
            List<decimal> answer = new List<decimal>();
            List<string> a = new List<string>();
            string line;
            while (true)
            {
                line = Console.ReadLine();

                answer.Clear();
                coll.Clear();
                a.AddRange(line.Split());
                a.RemoveAll(x => x.Equals(""));

                for (int i = 0; i < a.Count; i++)
                {
                    coll.Add(long.Parse(a[i]));

                }

                for (int i = 0; i < coll.Count; i++)
                {
                    var d = (decimal)Math.Sqrt(coll[i]);
                    answer.Insert(0, d);
                }
                Console.Clear();
                for (int i = 0; i < answer.Count; i++)
                {

                    Console.WriteLine(answer[i].ToString("0.0000##"));
                }
            }


Edited by author 21.02.2020 00:40