This is a very basic problem : Given two numbers up to 1 million, N and M.
And given N digits representing the first number. Then another M digits representing the second number.
ex :
INPUT
4 5
1 2 3 4
5 4 3 2 1
OUTPUT
66661
If you use Python then it is a very very very easy problem because Python supports numbers in a infinity of digits. But if you are a Java, C++ programmer then you can't do it like simple two number addition. So to do that, you just need to know how to addition big numbers at primary school. So you do :
remainder : nothing
1112
+ 34
-------
1146
So now I think you can implement it yourself (each time do addition then modulo 10), if anyone needs a C++ code, you can ask me.
No comments:
Post a Comment