A plus B... again

Given two integers A and B (of no more than 100000 digits each), find their exact sum.

All Submissions
Best Solutions

Point Value: 15
Time Limit: 3.00s
Memory Limit: 16M
Added: Oct 24, 2008

Problem Types: [Show]

Languages Allowed:
C++03, PAS, C, ASM, C#, C++11

Comments (Search)


cause that's too easy

My code WAs here, but ACs on DMOJ. Any reason why?
What happened to the test cases

Read the problem statement. It's only one sentence.

in java, just use long insted of int

There's another function to do, too.

It's not like it makes it any easier, we still have to use string manipulation because java variables can't store such big integers.

Java has a built-in BigInteger class. A sample Java solution for this problem is as follows:

import java.util.Scanner; 
import java.math.BigInteger;

public class aplusb2 {
public static void main(String[] foo) {
Scanner in = new Scanner(System.in);
System.out.println((new BigInteger(in.next())).add(new BigInteger(in.next())));

What's the difference between
public static void main(String[] args)
public static void main(String[] foo)?

If that's a sample Java solution for this problem, then why can't we submit it in JAVA? I mean, if you say that that is a way to solve it, then it means that there is a way to solve it in JAVA

what is the point of this problem?
isnt it just like the first one?

64 bit integers cannot hold numbers of 100000 digits (i.e., of size 10^100000)

yes, otherwise the problem would be trivial.

The program is not working!
Is there a catch? I have used the same program as the
first A + B.
For Some reason it no work!
Its very Simple!


readln (a);
readln (b);
writeln (a+b);

nothing to see here whistle.gif


Integers only have a capacity of -231 to 231 -1 which is 10 digits long while this problem has input that may be up to 100 000 digits each. So you'll have to find another method to solve this. For future reference don't post your code in the comments and please refer to this before posting a question.


The same as the title

It's exactly as the problem states: add two numbers together, each of which may be up to 100 000 digits long.

Note that python is disallowed because it has bignums.

Are A and B on the same line separated by a space or two separate lines?

Separate lines.