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.
Subscribe to:
Post Comments (Atom)
std::next_permutation(arr.begin(),arr.end());
What is next_permutation(a.begin(),a.end()) ? Next permutation is like what its name says, finds the next permutation of a and assigns ...
-
Usage of __int128_t: supports really big intermediate numbers, from -2^128 + 1 to 2^128 - 1 it has 128 bits Usage of __float128 : ...
-
This is one of the not interactive question. (2 out of 4 questions are interactive questions). You can try it ! InfO(1) CUP 2019 Third ...
-
There are many different distances but today we will be talking about Manhattan distance and Euclidean distance. Mahattan distance is based ...
No comments:
Post a Comment