Task: | ModAdd |
Sender: | rafaykh |
Submission time: | 2016-09-24 16:13:50 +0300 |
Language: | C++ |
Status: | READY |
Result: | TIME LIMIT EXCEEDED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.05 s | details |
#2 | ACCEPTED | 0.08 s | details |
#3 | ACCEPTED | 0.10 s | details |
#4 | ACCEPTED | 0.10 s | details |
#5 | ACCEPTED | 0.09 s | details |
#6 | ACCEPTED | 0.07 s | details |
#7 | ACCEPTED | 0.10 s | details |
#8 | TIME LIMIT EXCEEDED | -- | details |
#9 | ACCEPTED | 0.08 s | details |
#10 | ACCEPTED | 0.05 s | details |
Compiler report
input/code.cpp: In function 'int main(int, char**)': input/code.cpp:33:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if(i >= a.length() - b.length()){ ^ input/code.cpp:43:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if(i >= b.length() - a.length()){ ^
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; cin >> b; long len, sel, j; j = 0; 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; long tempres; string finalres; ostringstream convert; for (long i = 0; i < len; i++) { if(sel == 1){ if(i >= a.length() - b.length()){ tempres = ((long)a[i] - 48) + ((long)b[j] - 48); // cout << 'A' << (int)a[i] - 48 << endl; j++; } else { tempres = (long)a[i] - 48; // cout << 'B' <<(int)a[i] - 48 << endl; } } else{ if(i >= b.length() - a.length()){ tempres = ((long)a[j] -48) + ((long)b[i] - 48); j++; } else { tempres = (long)b[i] - 48; } } tempres = tempres % 10; // cout << tempres << ' '; convert << tempres; } finalres = convert.str(); // bool canDo = true; long p = 0; do{ if(finalres[p] == '0'){ finalres.erase (p,1); } else { canDo = false; } }while(canDo); cout << finalres; }
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... |
Test 3
Verdict: ACCEPTED
input |
---|
860793811134668093345482099582... |
correct output |
---|
487710306894083216377653715430... |
user output |
---|
487710306894083216377653715430... |
Test 4
Verdict: ACCEPTED
input |
---|
2 870841652294197226626825161089... |
correct output |
---|
870841652294197226626825161089... |
user output |
---|
870841652294197226626825161089... |
Test 5
Verdict: ACCEPTED
input |
---|
0 404905566051213252279994991040... |
correct output |
---|
404905566051213252279994991040... |
user output |
---|
404905566051213252279994991040... |
Test 6
Verdict: ACCEPTED
input |
---|
430112167406460960088878635088... |
correct output |
---|
430112167406460960088878635088... |
user output |
---|
430112167406460960088878635088... |
Test 7
Verdict: ACCEPTED
input |
---|
867016005819001635643395991596... |
correct output |
---|
999999999999999999999999999999... |
user output |
---|
999999999999999999999999999999... |
Test 8
Verdict: TIME LIMIT EXCEEDED
input |
---|
120453771521975552204976752778... |
correct output |
---|
0 |
user output |
---|
(empty) |
Test 9
Verdict: ACCEPTED
input |
---|
239979749009277805816504910098... |
correct output |
---|
239979749009277805816504910098... |
user output |
---|
239979749009277805816504910098... |
Test 10
Verdict: ACCEPTED
input |
---|
990963963634143754324162574923... |
correct output |
---|
818540385713473048971388312665... |
user output |
---|
818540385713473048971388312665... |