Task: | ModAdd |
Sender: | idan |
Submission time: | 2016-09-24 15:24:15 +0300 |
Language: | C++ |
Status: | READY |
Result: | RUNTIME ERROR |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.05 s | details |
#2 | RUNTIME ERROR | 0.15 s | details |
#3 | RUNTIME ERROR | 0.13 s | details |
#4 | RUNTIME ERROR | 0.14 s | details |
#5 | RUNTIME ERROR | 0.14 s | details |
#6 | RUNTIME ERROR | 0.15 s | details |
#7 | RUNTIME ERROR | 0.16 s | details |
#8 | RUNTIME ERROR | 0.15 s | details |
#9 | RUNTIME ERROR | 0.16 s | details |
#10 | RUNTIME ERROR | 0.15 s | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:31:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%s", numA); ^ input/code.cpp:32:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%s", numB); ^
Code
/********************************** Class: MAGSHIMIM C2 ** Week 1 ***********************************/#include <stdio.h>#include <math.h>#include <string.h>char *strrev(char *str){char c, *front, *back;if (!str || !*str)return str;for (front = str, back = str + strlen(str) - 1; front < back; front++, back--){c = *front; *front = *back; *back = c;}return str;}int main(void){int i = 0, currentAlsd = 0, currentBlsd = 0, currentDigit = 0;char numA[100000] = { 0 };char numB[100000] = { 0 };char result[100000] = { 0 };scanf("%s", numA);scanf("%s", numB);int aIndex = strlen(numA) - 1;int bIndex = strlen(numB) - 1;int maxLength = strlen(numA) > strlen(numB) ? strlen(numA) : strlen(numB);//printf("MaxLength : %d", maxLength);//system("pause");for (i = 0; i < maxLength; i++){currentAlsd = aIndex < 0 ? 0 : numA[aIndex--] - '0';currentBlsd = bIndex < 0 ? 0 : numB[bIndex--] - '0';currentDigit = (currentAlsd + currentBlsd) % 10;result[i] = currentDigit + '0';//puts(result);//printf("iteration %d : A lsd: %d B lsd: %d", i, currentAlsd, currentBlsd);}puts(strrev(result));//system("Pause");}
Test details
Test 1
Verdict: ACCEPTED
input |
---|
3797629225 9766508989 |
correct output |
---|
2453127104 |
user output |
---|
2453127104 |
Test 2
Verdict: RUNTIME ERROR
input |
---|
552139016901047883384892240490... |
correct output |
---|
552139016901047883384892240490... |
user output |
---|
(empty) |
Test 3
Verdict: RUNTIME ERROR
input |
---|
860793811134668093345482099582... |
correct output |
---|
487710306894083216377653715430... |
user output |
---|
(empty) |
Test 4
Verdict: RUNTIME ERROR
input |
---|
2 870841652294197226626825161089... |
correct output |
---|
870841652294197226626825161089... |
user output |
---|
(empty) |
Test 5
Verdict: RUNTIME ERROR
input |
---|
0 404905566051213252279994991040... |
correct output |
---|
404905566051213252279994991040... |
user output |
---|
(empty) |
Test 6
Verdict: RUNTIME ERROR
input |
---|
430112167406460960088878635088... |
correct output |
---|
430112167406460960088878635088... |
user output |
---|
(empty) |
Test 7
Verdict: RUNTIME ERROR
input |
---|
867016005819001635643395991596... |
correct output |
---|
999999999999999999999999999999... |
user output |
---|
(empty) |
Test 8
Verdict: RUNTIME ERROR
input |
---|
120453771521975552204976752778... |
correct output |
---|
0 |
user output |
---|
(empty) |
Test 9
Verdict: RUNTIME ERROR
input |
---|
239979749009277805816504910098... |
correct output |
---|
239979749009277805816504910098... |
user output |
---|
(empty) |
Test 10
Verdict: RUNTIME ERROR
input |
---|
990963963634143754324162574923... |
correct output |
---|
818540385713473048971388312665... |
user output |
---|
(empty) |