A Plus B (Hard)

View as PDF

Submit solution

Points:15 (partial)
Time limit:5.0s
Memory limit:64M

Problem type

Allowed languages
Assembly, C, C++, COBOL, Forth, Fortran, Java, Pascal, Prolog, Text

Xyene's teacher realized that he was cheating, and was using the code you wrote to save his marks. So, the math teacher decided that he will mess up your program by using numbers larger than 2^{64}. In fact, he will give problems involving addition of 100\,000-digit numbers as punishment. However, Xyene is once again on top — he has promised you a "reward" if you help him again. You suspect it might not be anything more than 15 points, but you still have your hopes up...

Input Specification

The first line will contain an integer N, the number of addition problems Xyene needs to do. The next N lines will each contain two space-separated integers with up to 100\,000 digits in decimal, the two integers Xyene needs to add. N will never be greater than 50. Warning: the test cases are a lot more sadistic than the sample.

Output Specification

Output N lines, the solutions to the addition problems in order.

Sample Input

1 1
226077045628835347875 -572260769919042128358
-803119834418378628674 236083700054616110639
-435599336891761067707 451767479989987922363

Sample Output



  • -3
     commented on Nov. 7, 2016, 12:15 p.m.

    The hard part seems to be parsing the input. It's really annoying to get a string that large from base 10 to base 2 (and back).

  • 4
     commented on Aug. 28, 2016, 5:36 p.m. edited
    Java is now allowed

    Java is now allowed for this problem, though use of the BigInteger and BigDecimal classes is disallowed.

  • 1
     commented on July 27, 2016, 7:15 p.m.
    Add Turing?

    Cuz it can't even handle 2^64.

  • -15
     commented on Oct. 26, 2015, 10:29 p.m.
    Why no JAVA?!

    Why can't we use java?

    • 0
       commented on April 15, 2016, 12:53 a.m.

      Judging by the GitHub page, Java could soon be allowed for this question, just with BigIntegers disabled.

      P.S. Xyene, you're also going to disable BigDecimal...right?

      • 0
         commented on April 15, 2016, 1:13 p.m. edited

        Yes, BigDecimal would be disabled. Support for disallowing big math is implemented judge-side, but it will likely be a while before we get to adding any kind of support for it on the site.

    • 2
       commented on Dec. 12, 2015, 5:10 a.m.

      Use Java?It's to simple.

    • 1
       commented on Nov. 24, 2015, 12:13 p.m.

      too young too simple sometimes naive

    • 5
       commented on Oct. 30, 2015, 11:32 a.m.

      Welcome to reality my friend

    • 10
       commented on Oct. 27, 2015, 2:59 p.m.


  • 0
     commented on June 20, 2015, 11:45 p.m.
    cant seem to find whats wrong

    tried so many cases nothing seems to give me the wrong answer. any suggestions?

  • -5
     commented on Nov. 29, 2014, 7:19 p.m.
    Can you guys add Java to this please.

    And please don't beef me, I need them 15 points.

    • 5
       commented on Nov. 29, 2014, 7:35 p.m.

      The difficulty of this in Java is the same as the regular aplusb (i.e. not worth 15 points).

      • -3
         commented on Nov. 29, 2014, 7:52 p.m.

        It is pretty hard...

        • -4
           commented on Nov. 29, 2014, 8:05 p.m.

          he refers to Big Integers

      • -4
         commented on Nov. 29, 2014, 7:41 p.m.

        Awww :(