PROBLEM LINK:
Author:Trung Nguyen
Tester:Oleksandr Kulkov
Editorialist:Oleksandr Kulkov
DIFFICULTY:
CAKEWALK
PREREQUISITES:
None
PROBLEM:
You're given two numbers. Sum them up without carrying.
QUICK EXPLANATION:
Just do what is written in statement.
EXPLANATION:
One of possible codes to solve the problem:
int a, b;
cin >> a >> b;
vector<int> A, B;
while(a) {
A.push_back(a % 10);
a /= 10;
}
while(b) {
B.push_back(b % 10);
b /= 10;
}
while(A.size() < B.size()) A.push_back(0);
while(B.size() < A.size()) B.push_back(0);
for(int i = 0; i < A.size(); i++) {
A[i] += B[i];
}
int ans = 0;
reverse(begin(A), end(A));
for(auto it: A) {
ans = ans * 10 + it % 10;
}
cout << ans << endl;
AUTHOR'S AND TESTER'S SOLUTIONS:
Author's solution can be found here.
Tester's solution can be found here.