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 1048. Superlong Sums

failed on test 2 , pls help! (C#)
Posted by TyrionZhou 29 Dec 2015 20:40
here's my code.Please give me some advise or test data!

            int n = int.Parse(Console.ReadLine());
            int nCopy = n;
            int sum = 0;
            string[] array = new string[2];
            short digitSum = 0;
            while(n-- != 0)
            {
                digitSum = 0;
                array = Console.ReadLine().Split(' ');
                foreach(var i in array)
                {
                    digitSum += short.Parse(i);
                }
                sum += digitSum * (int)Math.Pow(10, n);
            }

            Console.WriteLine(sum.ToString().Length > nCopy ? sum.ToString().Substring(1):sum.ToString().PadLeft(nCopy,'0'));
Re: failed on test 2 , pls help! (C#)
Posted by ToadMonster 30 Dec 2015 16:54
From task description:
> (1 ≤ N ≤ 1 000 000)

Why do you think you are able to put result into 32-bit (10 digits max) int variable?