| Task: | ModAdd |
| Sender: | hugues.verlin |
| Submission time: | 2016-09-24 15:11:41 +0300 |
| Language: | C++ |
| Status: | READY |
| Result: | ACCEPTED |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.05 s | details |
| #2 | ACCEPTED | 0.08 s | details |
| #3 | ACCEPTED | 0.13 s | details |
| #4 | ACCEPTED | 0.09 s | details |
| #5 | ACCEPTED | 0.11 s | details |
| #6 | ACCEPTED | 0.11 s | details |
| #7 | ACCEPTED | 0.09 s | details |
| #8 | ACCEPTED | 0.07 s | details |
| #9 | ACCEPTED | 0.10 s | details |
| #10 | ACCEPTED | 0.06 s | details |
Code
using namespace std;
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define pb push_back
#define clr clear()
#define inf (1<<30)
#define eps 1e-9
typedef long long i64;
typedef unsigned long long ui64;
#include <math.h>
int main() {
ios_base::sync_with_stdio(0);
string a, b;
cin >> a >> b;
int nb_digit_a = a.length();
int nb_digit_b = b.length();
vector<int> va;
for(int i = nb_digit_a - 1 ; i >= 0 ; i--){
va.push_back(a[i] - '0');
}
vector<int> vb;
for(int i = nb_digit_b - 1 ; i >= 0 ; i--){
vb.push_back(b[i] - '0');
}
int max_digit = max(nb_digit_a, nb_digit_b);
vector<int> res;
for(int i = 0; i < max_digit; i++){
if(i < nb_digit_a && i < nb_digit_b){
res.push_back((va[i] + vb[i]) % 10);
}else if(i >= nb_digit_b && i < nb_digit_a){
res.push_back((va[i]) % 10);
}else {
res.push_back((vb[i]) % 10);
}
}
reverse(res.begin(), res.end());
bool leading = true;
bool no_ouput = true;
for(auto it : res){
if(it != 0 && leading){
leading = false;
}
if(it != 0 || !leading){
no_ouput = false;
cout << it;
}
}
if(no_ouput){
cout << 0;
}
cout << endl;
return 0;
}
Test details
Test 1
Verdict: ACCEPTED
| input |
|---|
| 3797629225 9766508989 |
| correct output |
|---|
| 2453127104 |
| user output |
|---|
| 2453127104 |
Test 2
Verdict: ACCEPTED
| input |
|---|
| 552139016901047883384892240490... |
| correct output |
|---|
| 552139016901047883384892240490... |
| user output |
|---|
| 552139016901047883384892240490... Truncated |
Test 3
Verdict: ACCEPTED
| input |
|---|
| 860793811134668093345482099582... |
| correct output |
|---|
| 487710306894083216377653715430... |
| user output |
|---|
| 487710306894083216377653715430... Truncated |
Test 4
Verdict: ACCEPTED
| input |
|---|
| 2 870841652294197226626825161089... |
| correct output |
|---|
| 870841652294197226626825161089... |
| user output |
|---|
| 870841652294197226626825161089... Truncated |
Test 5
Verdict: ACCEPTED
| input |
|---|
| 0 404905566051213252279994991040... |
| correct output |
|---|
| 404905566051213252279994991040... |
| user output |
|---|
| 404905566051213252279994991040... Truncated |
Test 6
Verdict: ACCEPTED
| input |
|---|
| 430112167406460960088878635088... |
| correct output |
|---|
| 430112167406460960088878635088... |
| user output |
|---|
| 430112167406460960088878635088... Truncated |
Test 7
Verdict: ACCEPTED
| input |
|---|
| 867016005819001635643395991596... |
| correct output |
|---|
| 999999999999999999999999999999... |
| user output |
|---|
| 999999999999999999999999999999... Truncated |
Test 8
Verdict: ACCEPTED
| input |
|---|
| 120453771521975552204976752778... |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 9
Verdict: ACCEPTED
| input |
|---|
| 239979749009277805816504910098... |
| correct output |
|---|
| 239979749009277805816504910098... |
| user output |
|---|
| 239979749009277805816504910098... Truncated |
Test 10
Verdict: ACCEPTED
| input |
|---|
| 990963963634143754324162574923... |
| correct output |
|---|
| 818540385713473048971388312665... |
| user output |
|---|
| 818540385713473048971388312665... Truncated |
