| Task: | ModAdd |
| Sender: | rafaykh |
| Submission time: | 2016-09-24 15:19:41 +0300 |
| Language: | C++ |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | WRONG ANSWER | 0.06 s | details |
| #2 | WRONG ANSWER | 0.09 s | details |
| #3 | WRONG ANSWER | 0.10 s | details |
| #4 | WRONG ANSWER | 0.08 s | details |
| #5 | WRONG ANSWER | 0.07 s | details |
| #6 | WRONG ANSWER | 0.08 s | details |
| #7 | ACCEPTED | 0.08 s | details |
| #8 | WRONG ANSWER | 0.05 s | details |
| #9 | WRONG ANSWER | 0.08 s | details |
| #10 | WRONG ANSWER | 0.06 s | details |
Code
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
int main(int argc, char **argv)
{
using namespace std;
ios::sync_with_stdio(0);
string a, b;
cin >> a >> b;
int len, sel, j;
if (a.length() > b.length()){
sel = 1;
len = a.length();
j = b.length()-1;
} else {
sel = 2;
len = b.length();
j = a.length()-1;
}
// cout << (int)a[1] - 48;
int tempres;
string finalres;
ostringstream convert;
for (int i = len - 1; i >= 0; i--)
{
if(sel == 1){
if(j >= 0){
tempres = ((int)a[i] - 48) + ((int)b[j] - 48);
// cout << 'A' << (int)a[i] - 48 << endl;
j--;
} else {
tempres = (int)a[i] - 48;
// cout << 'B' <<(int)a[i] - 48 << endl;
}
}
else{
if(j >= 0){
tempres = ((int)a[j] -48) + ((int)b[i] - 48);
j--;
} else {
tempres = (int)b[i] - 48;
}
}
tempres = tempres % 10;
// cout << tempres << ' ';
if(tempres != 0){
convert << tempres;
}
}
finalres = convert.str();
std::reverse(finalres.begin(), finalres.end());
cout << finalres;
}
Test details
Test 1
Verdict: WRONG ANSWER
| input |
|---|
| 3797629225 9766508989 |
| correct output |
|---|
| 2453127104 |
| user output |
|---|
| 245312714 |
Test 2
Verdict: WRONG ANSWER
| input |
|---|
| 552139016901047883384892240490... |
| correct output |
|---|
| 552139016901047883384892240490... |
| user output |
|---|
| 552139169147883384892244942398... Truncated |
Test 3
Verdict: WRONG ANSWER
| input |
|---|
| 860793811134668093345482099582... |
| correct output |
|---|
| 487710306894083216377653715430... |
| user output |
|---|
| 487713689483216377653715437429... Truncated |
Test 4
Verdict: WRONG ANSWER
| input |
|---|
| 2 870841652294197226626825161089... |
| correct output |
|---|
| 870841652294197226626825161089... |
| user output |
|---|
| 878416522941972266268251618991... Truncated |
Test 5
Verdict: WRONG ANSWER
| input |
|---|
| 0 404905566051213252279994991040... |
| correct output |
|---|
| 404905566051213252279994991040... |
| user output |
|---|
| 449556651213252279994991426249... Truncated |
Test 6
Verdict: WRONG ANSWER
| input |
|---|
| 430112167406460960088878635088... |
| correct output |
|---|
| 430112167406460960088878635088... |
| user output |
|---|
| 431121674646968887863588915313... Truncated |
Test 7
Verdict: ACCEPTED
| input |
|---|
| 867016005819001635643395991596... |
| correct output |
|---|
| 999999999999999999999999999999... |
| user output |
|---|
| 999999999999999999999999999999... Truncated |
Test 8
Verdict: WRONG ANSWER
| input |
|---|
| 120453771521975552204976752778... |
| correct output |
|---|
| 0 |
| user output |
|---|
| (empty) |
Test 9
Verdict: WRONG ANSWER
| input |
|---|
| 239979749009277805816504910098... |
| correct output |
|---|
| 239979749009277805816504910098... |
| user output |
|---|
| 239979749927785816549198856323... Truncated |
Test 10
Verdict: WRONG ANSWER
| input |
|---|
| 990963963634143754324162574923... |
| correct output |
|---|
| 818540385713473048971388312665... |
| user output |
|---|
| 818543857134734897138831266538... Truncated |
