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

Please give me some advice!
Posted by Endorphin 23 Apr 2011 00:20
I've got WA on second test with code on C#:

using System;
using System.Numerics;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int n = int.Parse(s);

            string a1 = "";
            string b1 = "";

            for (int i = 0; i < n; i++)
            {
                string tmp = Console.ReadLine();
                a1 += tmp[0].ToString();
                b1 += tmp[2].ToString();
            }

            BigInteger a = BigInteger.Parse(a1);
            BigInteger b = BigInteger.Parse(b1);

            Console.WriteLine(a + b);
            Console.Read();
        }
    }
}

Could you tell me, where is my mistake?
Re: Please give me some advice!
Posted by AterLux 23 Apr 2011 01:11
I do not know C#, but, for example, in Java a + b not allowed to BigIntegers, may be you need to need a.add(b) instead?

Anyway, forget all your BigIntegers, Maps, Sets, ArrayLists and other chetering things: it's not sportsmanship ;)
Re: Please give me some advice!
Posted by Endorphin 24 Apr 2011 00:11
I tried to use a.add(b) instead. Nothing happened. :(
As for "chetering things", may be you are right...
Re: Please give me some advice!
Posted by Gio Pataraia [Tbilisi SU] 27 Apr 2011 04:24
why do you read integers as strings?
just read them us some array like this:
array a b;
4
0 4
4 2
6 8
3 7
when you see 4 resize arrays 4;
than int i=4;
while(i>0) read a[i],b[i]
than you have to sum them
 0 4 6 3
+4 2 8 7
--------
 4 7 5 0
Re: Please give me some advice!
Posted by Gio Pataraia [Tbilisi SU] 27 Apr 2011 04:25
p.s use Console.nextInt(); or nextShort() it also works :)
Re: Please give me some advice!
Posted by ssau_617_korabelnik 30 Oct 2011 04:35
do u try input in example?