Submit solution

Points:
15 (partial)

Time limit:
2.5s

Memory limit:
64M

Problem type

Allowed languages

Assembly, Brain****, C, C++, COBOL, Forth, Fortran, Java, Lua, Pascal, Prolog, Text, Turing

. In fact, he will give problems involving addition of -digit numbers as punishment. However, 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...

'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#### Input Specification

The first line will contain an integer , the number of addition problems needs to do. The next lines will each contain two space-separated integers with up to digits in decimal, the two integers needs to add. will never be greater than .

**Warning:** the test cases are a lot harder than the sample.

#### Output Specification

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

#### Sample Input

```
4
1 1
226077045628835347875 -572260769919042128358
-803119834418378628674 236083700054616110639
-435599336891761067707 451767479989987922363
```

#### Sample Output

```
2
-346183724290206780483
-567036134363762518035
16168143098226854656
```

## Comments

Can there be characters(other than '-') in the input? I debugged my code and found that the input contains characters, or is my debug code wrong?

EDIT: nvm my algorithm has a little error :)

Are there restrictions on N? (like 100 000 digits or something :P)

Edit: K good there aren't any.

Why do I only get the first and last test cases correct? (https://dmoj.ca/submission/1933893).

I tried a lot of different possible cases with huge numbers and I seemed to be getting correct results...

Edit: Nvm solved!

This comment is hidden due to too much negative feedback. Click here to view it.

Why is BF not an allowed language for this question?

The only practical way to solve even the original "A Plus B" in BF would require you to implement your own algorithm for addition of arbitrary-length integers.

BF has been enabled.

what does IR stand for?

Invalid Return, and for this problem you're not allowed to use BigInteger, as it is disabled for this problem.

oh thx

My output should be correct, but it says WA? (for test case 1 I tested my ac answers and found that they were the exact same as the wa answer)

This comment is hidden due to too much negative feedback. Click here to view it.

BigInteger is disabled

This comment is hidden due to too much negative feedback. Click here to view it.

Not sure why I'm WA on two cases. On case #2, the input is

`7808787 -2084742`

, and it WA because it's outputting 5403285 (wrong), but when I run the same input locally, it outputs 5724045 (right). I have no idea why this is happening. I thought it was because some variables weren't being reset, but all of the variables used in calculations are local. Any ideas?Why is my code out of range? I don't really understand it.

This comment is hidden due to too much negative feedback. Click here to view it.

Unfortunately, using a double is not sufficient enough (nor accurate enough) to store a 100000 digit number. Try finding another way you can store the digits (it may involve creating your own data structure).

coughcoughstringcoughcoughThis comment is hidden due to too much negative feedback. Click here to view it.

Can someone tell me what I'm doing wrong? Or at least give a case to test?

try

99 99 -99 99 99 -99 100 99 -100 99 100 -99

Can someone give a hint as to why my submission isn't passing? I've tried many of my own test cases (up to 100,000 characters) and they all passed on my side

Might need a wee bit more testing, 2 + 10 isn't 3 :(

damn thanks lol, apparently i misinterpreted how

`string::operator>`

workedCan we enable turing for this question?

Done, good luck!

Code is correct, output compares correctly, still WAs. Anyone have any idea why?

If you look at your output for test case 6 (on your most recent submission), there is a leading zero after the negative. Get rid of that.

Fixed that, but there's still something wrong with the output..... Any suggestions?

Can the two integers have leading zeros?

No

do we convert it to string first?

But why isn't python2 and lua allowed :v(

The difficulty of this in Python is the same as the regular aplusb (i.e. not worth 15 points). I've enabled Lua.

This comment is hidden due to too much negative feedback. Click here to view it.

Because copy/pasting code from Java's

`BigInteger`

implementation was never intended as a correct solution to this problem.`BigInteger`

isexplicitlydisallowed, so why would copypasta of it be any different?Java is now allowed for this problem, though use of the

`BigInteger`

and`BigDecimal`

classes is disallowed.Thanks!

This comment is hidden due to too much negative feedback. Click here to view it.

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?

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.This comment is hidden due to too much negative feedback. Click here to view it.

This comment is hidden due to too much negative feedback. Click here to view it.

Welcome to reality my friend

http://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html#add(java.math.BigInteger)

This comment is hidden due to too much negative feedback. Click here to view it.

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

This comment is hidden due to too much negative feedback. Click here to view it.

This comment is hidden due to too much negative feedback. Click here to view it.

This comment is hidden due to too much negative feedback. Click here to view it.