submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s470644187
p00015
C
#include <stdio.h> #include <string.h> int main(void) { int n, i, j, fa, fb, carry, ans[100]; char a[101], b[101]; scnaf("%d", &n); while(n--){ scnaf("%s", a); scnaf("%s", b); if(strlen(a) > 80 || strlen(b) > 80){ printf("overflow\n"); continue; } fa = strlen(a); fb = strlen(b); j = carry = 0; while(fa || fb){ if(fa) ans[j] += a[--fa] - '0'; if(fb) ans[j] += b[--fb] - '0'; carry = ans[j] / 10; if(carry) ans[j+1] += 1; else ans[j] %= 10; j++; } if(j >= 80){ printf("overflow\n"); continue; } for(; j >= 0; j--) printf("%d", ans[j]); printf("\n"); } return 0; }
main.c: In function 'main': main.c:9:3: error: implicit declaration of function 'scnaf'; did you mean 'scanf'? [-Wimplicit-function-declaration] 9 | scnaf("%d", &n); | ^~~~~ | scanf
s083942748
p00015
C
#include<stdio.h> int main(void){ int sum, N, i; long a, b; scanf("%d", &N); for ( i = 0; i < N, i++ ) { scanf("%d %d", a, b); if( a >= 10 * 80 || b = 10 * 8 || ( a + b ) >= 10 * 8) printf("overflow"); else printf("%d", a + b); } return 0; }
main.c: In function 'main': main.c:6:27: error: expected ';' before ')' token 6 | for ( i = 0; i < N, i++ ) { | ^~ | ; main.c:8:29: error: lvalue required as left operand of assignment 8 | if( a >= 10 * 80 || b = 10 * 8 || ( a + b ) >= 10 * 8) printf("overflow"); | ^
s205274465
p00015
C
//‘½”{’·‚̘a #include<stdio.h> #define N 10000 void mpStr2Num(char *str,int *num)//”Žš—ñ‚𑽔{’·®”‚É { char *ss; int *nn; int k; int x; while (*str == ' ' || *str == '\t') str++; while (*str == '0') str++; ss = str; while (*ss >= '0' && *ss <= '9') ss++; if (ss == str) { *num = 0; return; } x = 0; k = 1; nn = num; do { x += (*--ss - '0') * k; k *= 10; if (k == N || ss == str) { *++nn = x; x = 0; k = 1; } } while (ss != str); *num = nn - num; } void mpNum2Str(int *num,char *str)//‘½”{’·®”‚𐔎š—ñ‚É { int i, j; char *ss; int x; if (*num == 0) { *str++ = '0'; *str = '\0'; return; } ss = str - 1; for (i = *num; i > 0; i--) { x = *++num; for (j = 1; j < N; j *= 10) { *++ss = x % 10 + '0'; x /= 10; } } while (*ss == '0') ss--; *(ss + 1) = '\0'; while (str < ss) { x = *str; *str++ = *ss; *ss-- = x; } } void mpAdd(int *ret, int *a, int *b) { int i; int lr, la, lb; int *rr; int x; la = *a; lb = *b; lr = (la >= lb) ? la : lb; rr = ret; x = 0; for (i = 1; i <= lr; i++) { if (i <= la) x += *++a; if (i <= lb) x += *++b; if (x < N) { *++rr = x; x = 0; } else { *++rr = x - N; x = 1; } } *++rr = x; *ret = lr + x; } int main(void){ int s[30],a[30],b[30]; char ss[80],aa[80],bb[80]; gets(aa); mpStr2Num(aa,a); gets(bb); mpStr2Num(bb,b); mpAdd(s,a,b); mpNum2Str(s,ss); printf("%s\n",ss); return 0; }
main.c: In function 'main': main.c:100:9: error: implicit declaration of function 'gets'; did you mean 'fgets'? [-Wimplicit-function-declaration] 100 | gets(aa); | ^~~~ | fgets
s526936240
p00015
C
//‘½”{’·‚̘a #include<stdio.h> #include<string.h> #define N 10000 void mpStr2Num(char *str,int *num)//”Žš—ñ‚𑽔{’·®”‚É { char *ss; int *nn; int k; int x; while (*str == ' ' || *str == '\t') str++; while (*str == '0') str++; ss = str; while (*ss >= '0' && *ss <= '9') ss++; if (ss == str) { *num = 0; return; } x = 0; k = 1; nn = num; do { x += (*--ss - '0') * k; k *= 10; if (k == N || ss == str) { *++nn = x; x = 0; k = 1; } } while (ss != str); *num = nn - num; } void mpNum2Str(int *num,char *str)//‘½”{’·®”‚𐔎š—ñ‚É { int i, j; char *ss; int x; if (*num == 0) { *str++ = '0'; *str = '\0'; return; } ss = str - 1; for (i = *num; i > 0; i--) { x = *++num; for (j = 1; j < N; j *= 10) { *++ss = x % 10 + '0'; x /= 10; } } while (*ss == '0') ss--; *(ss + 1) = '\0'; while (str < ss) { x = *str; *str++ = *ss; *ss-- = x; } } void mpAdd(int *ret, int *a, int *b) { int i; int lr, la, lb; int *rr; int x; la = *a; lb = *b; lr = (la >= lb) ? la : lb; rr = ret; x = 0; for (i = 1; i <= lr; i++) { if (i <= la) x += *++a; if (i <= lb) x += *++b; if (x < N) { *++rr = x; x = 0; } else { *++rr = x - N; x = 1; } } *++rr = x; *ret = lr + x; } int main(void){ int s[30],a[30],b[30]; char ss[80],aa[80],bb[80]; int n,cnt,i; memset(ss,'\0',sizeof(ss)); memset(aa,'\0',sizeof(aa)); memset(bb,'\0',sizeof(bb)); scanf("%d ",&n); while(n--){ cnt=0; gets(aa); mpStr2Num(aa,a); gets(bb); mpStr2Num(bb,b); mpAdd(s,a,b); mpNum2Str(s,ss); for(i=0;i<81;i++){ if(ss[i]!='\0'){ cnt++; } if(cnt>=9){ printf("overflow\n"); goto end; } } printf("%s\n",ss); end: } return 0; }
main.c: In function 'main': main.c:108:9: error: implicit declaration of function 'gets'; did you mean 'fgets'? [-Wimplicit-function-declaration] 108 | gets(aa); | ^~~~ | fgets
s067998119
p00015
C
//‘½”{’·‚̘a #include<stdio.h> #include<string.h> #define N 10000 void mpStr2Num(char *str,int *num)//”Žš—ñ‚𑽔{’·®”‚É { char *ss; int *nn; int k; int x; while (*str == ' ' || *str == '\t') str++; while (*str == '0') str++; ss = str; while (*ss >= '0' && *ss <= '9') ss++; if (ss == str) { *num = 0; return; } x = 0; k = 1; nn = num; do { x += (*--ss - '0') * k; k *= 10; if (k == N || ss == str) { *++nn = x; x = 0; k = 1; } } while (ss != str); *num = nn - num; } void mpNum2Str(int *num,char *str)//‘½”{’·®”‚𐔎š—ñ‚É { int i, j; char *ss; int x; if (*num == 0) { *str++ = '0'; *str = '\0'; return; } ss = str - 1; for (i = *num; i > 0; i--) { x = *++num; for (j = 1; j < N; j *= 10) { *++ss = x % 10 + '0'; x /= 10; } } while (*ss == '0') ss--; *(ss + 1) = '\0'; while (str < ss) { x = *str; *str++ = *ss; *ss-- = x; } } void mpAdd(int *ret, int *a, int *b) { int i; int lr, la, lb; int *rr; int x; la = *a; lb = *b; lr = (la >= lb) ? la : lb; rr = ret; x = 0; for (i = 1; i <= lr; i++) { if (i <= la) x += *++a; if (i <= lb) x += *++b; if (x < N) { *++rr = x; x = 0; } else { *++rr = x - N; x = 1; } } *++rr = x; *ret = lr + x; } int main(void){ int s[30],a[30],b[30]; char ss[80],aa[80],bb[80]; int n,cnt,i; memset(ss,'\0',sizeof(ss)); memset(aa,'\0',sizeof(aa)); memset(bb,'\0',sizeof(bb)); scanf("%d ",&n); while(n--){ cnt=0; gets(aa); mpStr2Num(aa,a); gets(bb); mpStr2Num(bb,b); mpAdd(s,a,b); mpNum2Str(s,ss); for(i=0;i<81;i++){ if(ss[i]!='\0'){ cnt++; } if(cnt>=9){ printf("overflow\n"); cnt=-6; } } if(cnt>=0){ printf("%s\n",ss); } } return 0; }
main.c: In function 'main': main.c:108:9: error: implicit declaration of function 'gets'; did you mean 'fgets'? [-Wimplicit-function-declaration] 108 | gets(aa); | ^~~~ | fgets
s253377946
p00015
C
#include <stdio.h> #include <string.h> #include <stdlib.h> int atoiLonger(char a[],long num[]){ int length; int i,j,k=0; char temp[10]; for(i=0;i<9;i++){/*--*/ temp[i]=0; } temp[9]='\0'; length=strlen(a); for(j=0;j<9;j++){ temp[j]='0'; } j=8; for(i=length-1;i>=0;i--){ temp[j]=a[i]; if(j==0){ num[k]=atoi(temp); k++; for(j=0;j<9;j++){ temp[j]='0'; } j=8; }else{ j--; } } num[k]=atoi(temp); return 0; } int plus(long a[],long b[],long c[]){ int temp,i,flag=0; for(i=0;i<9;i++){ temp=a[i]+b[i]+flag; flag=0; if (temp>=1000000000){ temp-=1000000000; flag=1; } c[i]=temp; /* printf("%dŒ…–Ú:%d+%d=%d(Œ…‚ ‚Ó‚ê%d)\n",i,a[i],b[i],c[i],flag); */ } return flag; } int printLongNumber(long a[]){ int i,flag=0; for(i=8;i>=0;i--){ if(a[i]!=0 || flag==1){ if (flag==0){ printf("%d",a[i]); flag=1; }else{ printf("%09d",a[i]); } } } printf("\n"); return 0; } int scan(char a[]){ /*char irane[100000]; */ /*‘å‚«‚·‚¬H*/ int i; /* for(i=0;i<100000;i++){ /*--*/ irane[i]=0; } */ a[81]='a'; scanf("%s",a); if(a[81]!='a'){ printf("overflow\n"); scanf("%*s"); return 1; } return 0; } int main(){ char a[82],b[82]; long numA[9],numB[9],numC[9]; int i,j,cnt; scanf("%d",&cnt); for(j=0;j<cnt;j++){ for(i=0;i<9;i++){ numA[i]=0; numB[i]=0; numC[i]=0; } /* */ for(i=0;i<82;i++){ a[i]='0'; b[i]='0'; /* */ } if(scan(a))continue; if(scan(b))continue; /* printf("%s\n%s\n",a,b); */ atoiLonger(a,numA); atoiLonger(b,numB); if(plus(numA,numB,numC)){ printf("overflow\n"); continue; } /* printLongNumber(numA); printLongNumber(numB); */ printLongNumber(numC); } return 0; }
main.c: In function 'scan': main.c:73:17: error: 'irane' undeclared (first use in this function) 73 | irane[i]=0; | ^~~~~ main.c:73:17: note: each undeclared identifier is reported only once for each function it appears in main.c: At top level: main.c:75:2: error: expected identifier or '(' before '/' token 75 | */ a[81]='a'; | ^ main.c:76:15: error: expected declaration specifiers or '...' before string constant 76 | scanf("%s",a); | ^~~~ main.c:76:20: error: unknown type name 'a' 76 | scanf("%s",a); | ^ main.c:77:9: error: expected identifier or '(' before 'if' 77 | if(a[81]!='a'){ | ^~ main.c:82:9: error: expected identifier or '(' before 'return' 82 | return 0; | ^~~~~~ main.c:83:1: error: expected identifier or '(' before '}' token 83 | } | ^
s736402975
p00015
C
#include<stdio.h> int main(){ int c,d; __int64 a,b; while(scanf("%d",&c)!=EOF){ for(d=0;d<c;d++){ scanf("%I64d",&a); scanf("%I64d",&b); printf("%I64d\n",a+b); } } return 0; }
main.c: In function 'main': main.c:5:9: error: unknown type name '__int64'; did you mean '__int64_t'? 5 | __int64 a,b; | ^~~~~~~ | __int64_t
s607901402
p00015
C
#include<stdio.h> #include <stdlib.h> int main(){ int c,d; __int64 *a,*b; while(scanf("%d",&c)!=EOF){ a=(__int64*)malloc(sizeof(int)*(c+1)); b=(__int64*)malloc(sizeof(int)*(c+1)); for(d=0;d<c;d++){ scanf("%I64d",&a[d]); scanf("%I64d",&b[d]); } for(d=0;d<c;d++){ printf("%I64d\n",a[d]+b[d]); } } return 0; }
main.c: In function 'main': main.c:6:9: error: unknown type name '__int64'; did you mean '__int64_t'? 6 | __int64 *a,*b; | ^~~~~~~ | __int64_t main.c:9:20: error: '__int64' undeclared (first use in this function); did you mean '__int64_t'? 9 | a=(__int64*)malloc(sizeof(int)*(c+1)); | ^~~~~~~ | __int64_t main.c:9:20: note: each undeclared identifier is reported only once for each function it appears in main.c:9:28: error: expected expression before ')' token 9 | a=(__int64*)malloc(sizeof(int)*(c+1)); | ^ main.c:10:28: error: expected expression before ')' token 10 | b=(__int64*)malloc(sizeof(int)*(c+1)); | ^
s173368306
p00015
C
#incllude<stdio.h> int Input(int *keta){ int x,y,buf; for(x=0;x<80;x++){ buf=getchar(); if(buf=='\n')break; for(y=0;y<80;y++){ if(y!=0||y!=79){ keta[y]=keta[y+1]; } keta[79]=buf; } } return 0; } int Plus(int *a,int *b,int *ans){ int c; for(c=79;c>=0;c--){ ans[c]+=(a[c]+b[c]); if(ans[c]>9){ ans[c]-=10 if(c==0){return 1;} else ans[c-1]++; } } return 0; } int main(){ int a[80],b[80],ans[80]; int z,x,y; int kazu; scanf("%d",&kazu); for(z=0;z<kazu;z++){ for(x=0;x<80;x++){a[x]=0;b[x]=0;c[x]=0;ans[x]=0;} Input(a); Input(b); if(Plus(a,b,ans)){printf("overflow");} else { for(x=0;x<80;x++){ if(!ans[x]){ continue; } else printf("%d",ans[x]); } } } }
main.c:1:2: error: invalid preprocessing directive #incllude; did you mean #include? 1 | #incllude<stdio.h> | ^~~~~~~~ | include main.c: In function 'Input': main.c:5:21: error: implicit declaration of function 'getchar' [-Wimplicit-function-declaration] 5 | buf=getchar(); | ^~~~~~~ main.c:1:1: note: 'getchar' is defined in header '<stdio.h>'; this is probably fixable by adding '#include <stdio.h>' +++ |+#include <stdio.h> 1 | #incllude<stdio.h> main.c: In function 'Plus': main.c:21:35: error: expected ';' before 'if' 21 | ans[c]-=10 | ^ | ; 22 | if(c==0){return 1;} | ~~ main.c: In function 'main': main.c:33:9: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 33 | scanf("%d",&kazu); | ^~~~~ main.c:33:9: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:33:9: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] main.c:33:9: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:35:49: error: 'c' undeclared (first use in this function) 35 | for(x=0;x<80;x++){a[x]=0;b[x]=0;c[x]=0;ans[x]=0;} | ^ main.c:35:49: note: each undeclared identifier is reported only once for each function it appears in main.c:38:35: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 38 | if(Plus(a,b,ans)){printf("overflow");} | ^~~~~~ main.c:38:35: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:38:35: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:38:35: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:44:38: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] 44 | else printf("%d",ans[x]); | ^~~~~~ main.c:44:38: note: include '<stdio.h>' or provide a declaration of 'printf'
s127579810
p00015
C
#include<stdio.h> #include<string.h> #define Max 80 using namespace std; int main(){ int n, i, j; scanf("%d",&n); while(n--){ char str[100]; int ar[3][100], leng[3], ovf=0; for(i=0; i<100; i++) ar[0][i]=ar[1][i]=ar[2][i]=0; for(i=0; i<2; i++){ scanf(" %s",str); leng[i]=strlen(str); if(Max<leng[i]) ovf=1; for(j=0; j<leng[i];j++) ar[i][j]=str[leng[i]-1-j]-'0'; } for(i=0; i<100-1; i++){ int s =(ar[2][i]+ar[0][i]+ar[1][i]); ar[2][i] =s%10; ar[2][i+1]=s/10; } for(i=0; (i<100)&&(0==ar[2][100-1-i]); i++); leng[2]=100-i; if(Max<leng[2]) ovf=1; if(1==ovf) printf("overflow\n"); else{ for(i=0; i<leng[2]; i++) printf("%d",ar[2][leng[2]-1-i]); printf("\n"); } } return 0; }
main.c:6:1: error: unknown type name 'using' 6 | using namespace std; | ^~~~~ main.c:6:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'std' 6 | using namespace std; | ^~~
s008069850
p00015
C
//runtime error #include <stdio.h> #define SIZE 1<<8 char a[SIZE]; char b[SIZE]; char sum[SIZE + 1]; int main(void) { &#160; int n; &#160; int i, j; &#160; int alen, blen; &#160; char ch; &#160; int carry; &#160;&#160; &#160; scanf("%d", &n); &#160; ch = getchar(); &#160; for (i = 0; i < n; i++){ &#160; &#160; memset(a,0,sizeof(char) * (SIZE)); &#160; &#160; memset(b,0,sizeof(char) * (SIZE)); &#160; &#160; memset(sum,0,sizeof(char) * (SIZE + 1)); &#160; &#160;&#160; &#160; &#160; /* &#160; &#160; while((ch = getchar()) != '\n'); &#160; &#160; ungetc(ch,NULL); &#160; &#160; */ &#160; &#160; for (alen = 1; (ch = getchar()) != '\n' ; alen++){ &#160; &#160; &#160; a[alen] = ch - '0'; &#160; &#160; } &#160; &#160; for (blen = 1; (ch = getchar()) != '\n' ; blen++){ &#160; &#160; &#160; b[blen] = ch - '0'; &#160; &#160; } &#160; &#160; carry = 0; &#160; &#160; for (j = 0;; j++){ &#160; &#160; &#160; if(alen){ alen--; &#160; &#160; &#160; } &#160; &#160; &#160; if(blen){ blen--; &#160; &#160; &#160; } &#160; &#160; &#160; if (!(alen || blen || carry)){ break; &#160; &#160; &#160; } &#160; &#160; &#160; sum[j] = a[alen] + b[blen] + carry; &#160; &#160; &#160; carry = 0;&#160; &#160; &#160; &#160; while (sum[j] > 9){ sum[j] -= 10; carry++; &#160; &#160; &#160; } &#160; &#160; } &#160; &#160; for (j--; j >= 0; j--){ &#160; &#160; &#160; printf("%c", (sum[j] + '0')); &#160; &#160; } &#160; &#160; printf("\n"); &#160; } &#160; return 0; }
main.c: In function 'main': main.c:17:2: error: stray '#' in program 17 | &#160; int n; | ^ main.c:17:1: error: lvalue required as unary '&' operand 17 | &#160; int n; | ^ main.c:18:2: error: stray '#' in program 18 | &#160; int i, j; | ^ main.c:18:1: error: lvalue required as unary '&' operand 18 | &#160; int i, j; | ^ main.c:19:2: error: stray '#' in program 19 | &#160; int alen, blen; | ^ main.c:19:1: error: lvalue required as unary '&' operand 19 | &#160; int alen, blen; | ^ main.c:20:2: error: stray '#' in program 20 | &#160; char ch; | ^ main.c:20:1: error: lvalue required as unary '&' operand 20 | &#160; char ch; | ^ main.c:21:2: error: stray '#' in program 21 | &#160; int carry; | ^ main.c:21:1: error: lvalue required as unary '&' operand 21 | &#160; int carry; | ^ main.c:22:2: error: stray '#' in program 22 | &#160;&#160; | ^ main.c:22:1: error: lvalue required as unary '&' operand 22 | &#160;&#160; | ^ main.c:22:8: error: stray '#' in program 22 | &#160;&#160; | ^ main.c:22:7: error: lvalue required as unary '&' operand 22 | &#160;&#160; | ^ main.c:23:2: error: stray '#' in program 23 | &#160; scanf("%d", &n); | ^ main.c:23:1: error: lvalue required as unary '&' operand 23 | &#160; scanf("%d", &n); | ^ main.c:24:2: error: stray '#' in program 24 | &#160; ch = getchar(); | ^ main.c:24:1: error: lvalue required as unary '&' operand 24 | &#160; ch = getchar(); | ^ main.c:29:2: error: stray '#' in program 29 | &#160; for (i = 0; i < n; i++){ | ^ main.c:29:1: error: lvalue required as unary '&' operand 29 | &#160; for (i = 0; i < n; i++){ | ^ main.c:30:2: error: stray '#' in program 30 | &#160; &#160; memset(a,0,sizeof(char) * (SIZE)); | ^ main.c:30:1: error: lvalue required as unary '&' operand 30 | &#160; &#160; memset(a,0,sizeof(char) * (SIZE)); | ^ main.c:30:9: error: stray '#' in program 30 | &#160; &#160; memset(a,0,sizeof(char) * (SIZE)); | ^ main.c:30:8: error: lvalue required as unary '&' operand 30 | &#160; &#160; memset(a,0,sizeof(char) * (SIZE)); | ^ main.c:30:15: error: implicit declaration of function 'memset' [-Wimplicit-function-declaration] 30 | &#160; &#160; memset(a,0,sizeof(char) * (SIZE)); | ^~~~~~ main.c:3:1: note: include '<string.h>' or provide a declaration of 'memset' 2 | #include <stdio.h> +++ |+#include <string.h> 3 | #define SIZE 1<<8 main.c:30:15: warning: incompatible implicit declaration of built-in function 'memset' [-Wbuiltin-declaration-mismatch] 30 | &#160; &#160; memset(a,0,sizeof(char) * (SIZE)); | ^~~~~~ main.c:30:15: note: include '<string.h>' or provide a declaration of 'memset' main.c:31:2: error: stray '#' in program 31 | &#160; &#160; memset(b,0,sizeof(char) * (SIZE)); | ^ main.c:31:1: error: lvalue required as unary '&' operand 31 | &#160; &#160; memset(b,0,sizeof(char) * (SIZE)); | ^ main.c:31:9: error: stray '#' in program 31 | &#160; &#160; memset(b,0,sizeof(char) * (SIZE)); | ^ main.c:31:8: error: lvalue required as unary '&' operand 31 | &#160; &#160; memset(b,0,sizeof(char) * (SIZE)); | ^ main.c:32:2: error: stray '#' in program 32 | &#160; &#160; memset(sum,0,sizeof(char) * (SIZE + 1)); | ^ main.c:32:1: error: lvalue required as unary '&' operand 32 | &#160; &#160; memset(sum,0,sizeof(char) * (SIZE + 1)); | ^ main.c:32:9: error: stray '#' in program 32 | &#160; &#160; memset(sum,0,sizeof(char) * (SIZE + 1)); | ^ main.c:32:8: error: lvalue required as unary '&' operand 32 | &#160; &#160; memset(sum,0,sizeof(char) * (SIZE + 1)); | ^ main.c:33:2: error: stray '#' in program 33 | &#160; &#160;&#160; | ^ main.c:33:1: error: lvalue required as unary '&' operand 33 | &#160; &#160;&#160; | ^ main.c:33:9: error: stray '#' in program 33 | &#160; &#160;&#160; | ^ main.c:33:8: error: lvalue required as unary '&' operand 33 | &#160; &#160;&#160; | ^ main.c:33:15: error: stray '#' in program 33 | &#160; &#160;&#160; | ^ main.c:33:14: error: lvalue required as unary '&' operand 33 | &#160; &#160;&#160; | ^ main.c:34:2: error: stray '#' in program 34 | &#160; &#160; /* | ^ main.c:34:1: error: lvalue required as unary '&' operand 34 | &#160; &#160; /* | ^ main.c:34:9: error: stray '#' in program 34 | &#160; &#160; /* | ^ main.c:34:8: error: lvalue required as unary '&' operand 34 | &#160; &#160; /* | ^ main.c:42:2: error: stray '#' in program 42 | &#160; &#160; for (alen = 1; (ch = getchar()) != '\n' ; alen++){ | ^ main.c:42:1: error: lvalue required as unary '&' operand 42 | &#160; &#160; for (alen = 1; (ch = getchar()) != '\n' ; alen++){ | ^ main.c:42:9: error: stray '#' in program 42 | &#160; &#160; for (alen = 1; (ch = getchar()) != '\n' ; alen++){ | ^ main.c:42:8: error: lvalue required as unary '&' operand 42 | &#160; &#160; for (alen = 1; (ch = getchar()) != '\n' ; alen++){ | ^ main.c:43:2: error: stray '#' in program 43 | &#160; &#160; &#160; a[alen] = ch - '0'; | ^ main.c:43:1: error: lvalue required as unary '&' operand 43 | &#160; &#160; &#160; a[alen] = ch - '0'; | ^ main.c:43:9: error: stray '#' in program 43 | &#160; &#160; &#160; a[alen] = ch - '0'; | ^ main.c:43:8: error: lvalue required as unary '&' operand 43 | &#160; &#160; &#160; a[alen] = ch - '0'; | ^ main.c:43:16: error: stray '#' in program 43 | &#160; &#160; &#160; a[alen] = ch - '0'; | ^ main.c:43:15: error: lvalue required as unary '&' operand 43 | &#160; &#160; &#160; a[alen] = ch - '0'; | ^ main.c:44:2: error: stray '#' in program 44 | &#160; &#160; } | ^ main.c:44:1: error: lvalue required as unary '&' operand 44 | &#160; &#160; } | ^ main.c:44:9: error: stray '#' in program 44 | &#160; &#160; } | ^ main.c:44:8: error: lvalue required as unary '&' operand 44 | &#160; &#160; } | ^ main.c:45:2: error: stray '#' in program 45 | &#160; &#160; for (blen = 1; (ch = getchar()) != '\n' ; blen++){ | ^ main.c:45:1: error: lvalue required as unary '&' operand 45 | &#160; &#160; for (blen = 1; (ch = getchar()) != '\n' ; blen++){ | ^ main.c:45:9: error: stray '#' in program 45 | &#160; &#160; for (blen = 1; (ch = getchar()) != '\n' ; blen++){ | ^ main.c:45:8: error: lvalue required as unary '&' operand 45 | &#160; &#160; for (blen = 1; (ch = getchar()) != '\n' ; blen++){ | ^ main.c:46:2: error: stray '#' in program 46 | &#160; &#160; &#160; b[blen] = ch - '0'; | ^ main.c:46:1: error: lvalue required as unary '&' operand 46 | &#160; &#160; &#160; b[blen] = ch - '0'; | ^ main.c:46:9: error: stray '#' in program 46 | &#160; &#160; &#160; b[blen] = ch - '0'; | ^ main.c:46:8: error: lvalue required as unary '&' operand 46 | &#160; &#160; &#160; b[blen] = ch - '0'; | ^ main.c:46:16: error: stray '#' in program 46 | &#160; &#160; &#160; b[blen] = ch - '0'; | ^ main.c:46:15: error: lvalue required as unary '&' operand 46 | &#160; &#160; &#160; b[blen] = ch - '0'; | ^ main.c:47:2: error: stray '#' in program 47 | &#160; &#160; } | ^ main.c:47:1: error: lvalue required as unary '&' operand 47 | &#160; &#160; } | ^ main.c:47:9: error: stray '#' in program 47 | &#160; &#160; } | ^ main.c:47:8: error: lvalue required as unary '&' operand 47 | &#160; &#160; } | ^ main.c:52:2: error: stray '#' in program 52 | &#160; &#160; carry = 0; | ^ main.c:52:1: error: lvalue required as unary '&' operand 52 | &#160; &#160; carry = 0; | ^ main.c:52:9: error: stray '#' in program 52 | &#160; &#160; carry = 0; | ^ main.c:52:8: error: lvalue required as unary '&' operand 52 | &#160; &#160; carry = 0; | ^ main.c:53:2: error: stray '#' in program 53 | &#160; &#160; for (j = 0;; j++){ | ^ main.c:53:1: error: lvalue required as unary '&' operand 53 | &#160; &#160; for (j = 0;; j++){ | ^ main.c:53:9: error: stray '#' in program 53 | &#160; &#160; for (j = 0;; j++){ | ^ main.c:53:8: error: lvalue required as unary '&' operand 53 | &#160; &#160; for (j = 0;; j++){ | ^ main.c:54:2: error: stray '#' in program 54 | &#160; &#160; &#160; if(alen){ | ^ main.c:54:1: error: lvalue required as unary '&' operand 54 | &#160; &#160; &#160; if(alen){ | ^ main.c:54:9: error: stray '#' in program 54 | &#160; &#160; &#160; if(alen){ | ^ main.c:54:8: error: lvalue required as unary '&' operand 54 | &#160; &#160; &#160; if(alen){ | ^ main.c:54:16: error: stray '#' in program 54 | &#160; &#160; &#160; if(alen){ | ^ main.c:54:15: error: lvalue required as unary '&' operand 54 | &#160; &#160; &#160; if(alen){ | ^ main.c:56:2: error: stray '#' in program 56 | &#160; &#160; &#160; } | ^ main.c:56:1: error: lvalue required as unary '&' operand 56 | &#160; &#160; &#160; } | ^ main.c:56:9: error: stray '#' in program 56 | &#160; &#160; &#160; } | ^ main.c:56:8: error: lvalue required as unary '&' operand 56 | &#160; &#160; &#160; } | ^ main.c:56:16: error: stray '#' in program 56 | &#160; &#160; &#160; } | ^ main.c:56:15: error: lvalue required as unary '&' operand 56 | &#160; &#160; &#160; } | ^ main.c:57:2: error: stray '#' in program 57 | &#160; &#160; &#160; if(blen){ | ^ main.c:57:1: error: lvalue required as unary '&' operand 57 | &#160; &#160; &#160; if(blen){ | ^ main.c:57:9: error: stray '#' in program 57 | &#160; &#160; &#
s319203214
p00015
C
#include <stdio.h> #include <string.h> #include <ctype.h> int main() { char s1[125]; char s2[125]; char s3[125]; int i, j, n, leap = 0; int ans; scanf("%d", &n); for (i = 0; i < n; i++) { memset(s1, '0', 124); s1[124] = '\0'; memset(s2, '0', 124); s2[124] = '\0'; memset(s3, '0', 124); s3[124] = '\0'; scanf(" %s", s1); scanf(" %s", s2); if (strlen(s1) < strlen(s2)) { // s1を長くする strcpy(s3, s2); strcpy(s2, s1); strcpy(s1, s3); } strrev(s1); strrev(s2); for (j = 0; !(s1[j] == '\0' || s2[j] == '\0'); j++) { ans = (s1[j] - '0') + (s2[j] - '0') + leap; s1[j] = ans % 10 + '0'; leap = ans / 10; } for (; leap > 0; j++) { if (isdigit(s1[j])) { ans = (s1[j] - '0') + leap; s1[j] = ans % 10 + '0'; leap = ans / 10; } else { s1[j] = '1'; leap = 0; s1[j+1] = '\0'; } } strrev(s1); printf("%s\n", s1); } return 0; }
main.c: In function 'main': main.c:25:17: error: implicit declaration of function 'strrev'; did you mean 'strsep'? [-Wimplicit-function-declaration] 25 | strrev(s1); | ^~~~~~ | strsep
s611864006
p00015
C
#include <stdio.h> #include <string.h> #include <ctype.h> int main() { char s1[125]; char s2[125]; char s3[125]; int i, j, n, leap = 0; int ans; scanf("%d", &n); for (i = 0; i < n; i++) { memset(s1, '0', 124); s1[124] = '\0'; memset(s2, '0', 124); s2[124] = '\0'; memset(s3, '0', 124); s3[124] = '\0'; scanf(" %s", s1); scanf(" %s", s2); if (strlen(s1) < strlen(s2)) { /* s1を長くする */ strcpy(s3, s2); strcpy(s2, s1); strcpy(s1, s3); } strrev(s1); strrev(s2); for (j = 0; !(s1[j] == '\0' || s2[j] == '\0'); j++) { ans = (s1[j] - '0') + (s2[j] - '0') + leap; s1[j] = ans % 10 + '0'; leap = ans / 10; } for (; leap > 0; j++) { if (isdigit(s1[j])) { ans = (s1[j] - '0') + leap; s1[j] = ans % 10 + '0'; leap = ans / 10; } else { s1[j] = '1'; leap = 0; s1[j+1] = '\0'; } } strrev(s1); printf("%s\n", s1); } return 0; }
main.c: In function 'main': main.c:25:17: error: implicit declaration of function 'strrev'; did you mean 'strsep'? [-Wimplicit-function-declaration] 25 | strrev(s1); | ^~~~~~ | strsep
s507088102
p00015
C
#include <stdio.h> #include <string.h> #include <ctype.h> int main() { char s1[125]; char s2[125]; char s3[125]; int i, j, n, leap = 0; int ans; scanf("%d", &n); for (i = 0; i < n; i++) { memset(s1, '0', 124); s1[124] = '\0'; memset(s2, '0', 124); s2[124] = '\0'; memset(s3, '0', 124); s3[124] = '\0'; scanf(" %s", s1); scanf(" %s", s2); if (strlen(s1) < strlen(s2)) { /* s1を長くする */ strcpy(s3, s2); strcpy(s2, s1); strcpy(s1, s3); } strrev(s1); strrev(s2); for (j = 0; !(s1[j] == '\0' || s2[j] == '\0'); j++) { ans = (s1[j] - '0') + (s2[j] - '0') + leap; s1[j] = ans % 10 + '0'; leap = ans / 10; } for (; leap > 0; j++) { if (isdigit(s1[j])) { ans = (s1[j] - '0') + leap; s1[j] = ans % 10 + '0'; leap = ans / 10; } else { s1[j] = '1'; leap = 0; s1[j+1] = '\0'; } } strrev(s1); printf("%s\n", s1); } return 0; }
main.c: In function 'main': main.c:25:17: error: implicit declaration of function 'strrev'; did you mean 'strsep'? [-Wimplicit-function-declaration] 25 | strrev(s1); | ^~~~~~ | strsep
s809088724
p00015
C
#include <stdio.h> #include <string.h> #include <stdlib.h> int main(){ int i,j,k,n,tmp,flag,length; int yosan[20]; char str[81],str2[1024],ans[5]; scanf("%d",&n); for(i = 0;i < n;i++){ memset(yosan,0,sizeof(yosan)); flag = 0; for(j = 0;j < 2;j++){ scanf("%s",str2); length = strlen(str2); if(!flag && length >= 81){ flag = 1; }else{ memset(str,' ',sizeof(str)); for(k = 0;k < 80;k++){ if(k >= 80-length){ str[k] = str2[k-80+length]; }else{ str[k] = '0'; } } str[80] = '\0'; //printf("%s\n",str); tmp = 0; for(k = 0;k < 80;k++){ tmp *= 10; tmp += (str[k] - '0'); if(k % 4 == 3){ yosan[k/4] += tmp; tmp = 0; } } for(k = 29;k > 0;k--){ if(yosan[k] >= 10000){ yosan[k-1]++; yosan[k] %= 10000; } } } } if(yosan[0] >= 10000){ flag = 1; } if(!flag){ tmp = 0; while(yosan[tmp] == 0){ tmp++; } itoa(yosan[tmp],ans,10); printf("%s",ans); tmp++; for(j = tmp;j < 20;j++){ sprintf(ans,"%04d",yosan[j]); printf("%s",ans); } printf("\n"); }else{ printf("overflow\n"); } } return 0; }
main.c: In function 'main': main.c:56:25: error: implicit declaration of function 'itoa' [-Wimplicit-function-declaration] 56 | itoa(yosan[tmp],ans,10); | ^~~~
s060576148
p00015
C
#include <stdio.h> #include <string.h> #include <stdlib.h> int main(){ int i,j,k,n,tmp,flag,length; int yosan[20]; char str[81],str2[1024],ans[5]; scanf("%d",&n); for(i = 0;i < n;i++){ memset(yosan,0,sizeof(yosan)); flag = 0; for(j = 0;j < 2;j++){ scanf("%s",str2); length = strlen(str2); if(!flag && length >= 81){ flag = 1; }else{ memset(str,'0',sizeof(str)); for(k = 0;k < 80;k++){ if(k >= 80-length){ str[k] = str2[k-80+length]; }else{ str[k] = '0'; } } str[80] = '\0'; //printf("%s\n",str); tmp = 0; for(k = 0;k < 80;k++){ tmp *= 10; tmp += (str[k] - '0'); if(k % 4 == 3){ yosan[k/4] += tmp; tmp = 0; } } for(k = 29;k > 0;k--){ if(yosan[k] >= 10000){ yosan[k-1]++; yosan[k] %= 10000; } } } } if(yosan[0] >= 1000){ flag = 1; } if(!flag){ tmp = 0; while(yosan[tmp] == 0){ tmp++; } itoa(yosan[tmp],ans,10); printf("%s",ans); tmp++; for(j = tmp;j < 20;j++){ sprintf(ans,"%04d",yosan[j]); printf("%s",ans); } printf("\n"); }else{ printf("overflow\n"); } } return 0; }
main.c: In function 'main': main.c:56:25: error: implicit declaration of function 'itoa' [-Wimplicit-function-declaration] 56 | itoa(yosan[tmp],ans,10); | ^~~~
s054333683
p00015
C
#include<stdio.h> int main(){ int i,n,j,k,l,F,S,e,sf,ss,st; char f[256],s[256],t[256]={}; scanf("%d%*c",&n); for(i=0;i<n;i++) { j=1; f[0] = '0'; while(1) { f[j]=getchar(); if(f[j] == '\n'){break;} else{j++;} } k=1; s[0] = '0'; while(1) { s[k]=getchar(); if(s[k] == '\n'){break;} else{k++;} } j--; k--; sf=j; ss=k; e=0; while(1) { if(j<0){f[j] = '0';} if(k<0){s[k] = '0';} F =f[j]-'0'; S =s[k]-'0'; if(j>=k){ if(j<0)break; if(F+S+e>=10){ t[j] =F+S+e-10 + '0'; e = 1; j--; k--; } else{ t[j] = F+S+e + '0'; e = 0; j--; k--; } } l=0; st=0; if(t[0]=='0'){l++;} else{st++;} if(sf>=ss){st=st+sf;} else{st=st+ss;} if(st>80){printf("overflow");} else{ while(l<80){ printf("%c",t[l]); l++; } } printf("\n"); } return 0; }
main.c: In function 'main': main.c:80:1: error: expected declaration or statement at end of input 80 | } | ^
s305915901
p00015
C
#include<stdio.h> int main(){ int i,n,j,k,l,F,S,e,sf,ss,st; char f[256],s[256],t[256]={}; scanf("%d%*c",&n); for(i=0;i<n;i++) { j=1; f[0] = '0'; while(1) { f[j]=getchar(); if(f[j] == '\n'){break;} else{j++;} } k=1; s[0] = '0'; while(1) { s[k]=getchar(); if(s[k] == '\n'){break;} else{k++;} } j--; k--; sf=j; ss=k; e=0; if(j>=k){ while(1) { if(j<0){f[j] = '0';} if(k<0){s[k] = '0';} F =f[j]-'0'; S =s[k]-'0'; if(j<0)break; if(F+S+e>=10){ t[j] =F+S+e-10 + '0'; e = 1; j--; k--; } else{ t[j] = F+S+e + '0'; e = 0; j--; k--; } } } if(j<k){ while(1) { if(j<0){f[j] = '0';} if(k<0){s[k] = '0';} F =f[j]-'0'; S =s[k]-'0'; if(k<0)break; if(F+S+e>=10){ t[k] = F+S+e-10 + '0'; e = 1; j--; k--; } else{ t[k] = F+S+e + '0'; e = 0; j--; k--; } } } } l=0; st=0; if(t[0]=='0'){l++;} else{st++;} if(sf>=ss){st=st+sf;} else{st=st+ss;} if(st>80){printf("overflow");} else{ while(l<80){ printf("%c",t[l]); l++; } } printf("\n"); } return 0; }
main.c:101:4: error: expected identifier or '(' before 'return' 101 | return 0; | ^~~~~~ main.c:102:1: error: expected identifier or '(' before '}' token 102 | } | ^
s929091654
p00015
C
#include <stdio.h> #include <string.h> int main(void) { char a[91],b[91]; int ca,i,n,m; scanf("%d",&n); while(scanf("%s",a)!=EOF){ scanf("%s",b) } return 0; }
main.c: In function 'main': main.c:11:22: error: expected ';' before '}' token 11 | scanf("%s",b) | ^ | ; 12 | } | ~
s450344144
p00015
C
#include <stdio.h> #include <string.h> int main(void) { char a[91],b[91]; int n; scanf("%d",&n); scanf("%s",a); scanf("%s",b); scanf("%s",a); scanf("%s",b); scanf("%s",a); scanf("%s",b); scanf("%s",a); scanf("%s",b); } return 0; }
main.c:20:9: error: expected identifier or '(' before 'return' 20 | return 0; | ^~~~~~ main.c:21:1: error: expected identifier or '(' before '}' token 21 | } | ^
s715511546
p00015
C
#include <stdio.h> int main(void) { __int64 a, b, sum; int keta; int n; int i; scanf("%d", &n); for (i = 0; i < n; i++){ scanf("%I64u", &a); scanf("%I64u", &b); sum = a + b; keta = 1; while (sum / 10 > 0){ keta++; sum /= 10; } if (keta > 80){ printf("overflow\n"); } else { sum = a + b; printf("%I64u\n", sum); } } return (0); }
main.c: In function 'main': main.c:5:9: error: unknown type name '__int64'; did you mean '__int64_t'? 5 | __int64 a, b, sum; | ^~~~~~~ | __int64_t
s000525606
p00015
C
#include <stdio.h> int main(void) { __int64 a, b, sum; int keta; int n; int i; scanf("%d", &n); for (i = 0; i < n; i++){ scanf("%I64u", &a); scanf("%I64u", &b); sum = a + b; keta = 1; while (sum / 10 > 0){ keta++; sum /= 10; } if (keta > 80){ printf("overflow\n"); } else { sum = a + b; printf("%I64u\n", sum); } } return (0); }
main.c: In function 'main': main.c:5:9: error: unknown type name '__int64'; did you mean '__int64_t'? 5 | __int64 a, b, sum; | ^~~~~~~ | __int64_t
s158370121
p00015
C
#include <stdio.h> int main(void){ int n; long long int a,b; scanf("%d",&n); while(n){ scanf("%d %d",&a,&B); printf("%d",a+b); n--; } return 0; }
main.c: In function 'main': main.c:7:32: error: 'B' undeclared (first use in this function) 7 | scanf("%d %d",&a,&B); | ^ main.c:7:32: note: each undeclared identifier is reported only once for each function it appears in
s672145648
p00015
C
#include <stdio.h> int main(){ int i, I; int n; scanf("%d", n); for(i=0;i<n;i++) { long long int a[100]={},b[100]={}; scanf("%lld %lld", &a[i], &b[i]); } for(I=0;I<i;I++) { printf("%lld\n", a[i]+b[i]); } return 0; }
main.c: In function 'main': main.c:14:34: error: 'a' undeclared (first use in this function) 14 | printf("%lld\n", a[i]+b[i]); | ^ main.c:14:34: note: each undeclared identifier is reported only once for each function it appears in main.c:14:39: error: 'b' undeclared (first use in this function) 14 | printf("%lld\n", a[i]+b[i]); | ^
s851481336
p00015
C
#include <stdio.h> #include <string.h> int main(void){ int n,ap,bp,cp,t; char a[81],b[81],c[81]; scanf("%d",&n); while(~scanf("%s%s",&a,&b)){ ap=strlen(a); bp=strlen(b); cp=sizeof(c)-1; c[cp]='\0'; t=0; while((t||ap||bp)&&cp>0){ t+=(ap?a[--ap]-'0':0)+(bp?b[--bp]-'0':0); c[--cp]='0'+(t%10); t/=10; } if(t)puts("overflow"); else puts("%s",&c[cp]); } return 0; }
main.c: In function 'main': main.c:19:14: error: too many arguments to function 'puts' 19 | else puts("%s",&c[cp]); | ^~~~ In file included from main.c:1: /usr/include/stdio.h:714:12: note: declared here 714 | extern int puts (const char *__s); | ^~~~
s844903502
p00015
C
#include<stdio.h> int main(void) { char a[82]={0},b[82]={0}; int i,k,N; scanf("%d",&N); for(i=0;i<N;i++){ for(k=0;k<82;k++) a[k]=b[k]=0: scanf("%82s",a); scanf("%82s",b); if(a[81]!=0||b[81]!=0){ printf("overflow\n"); } else{ for(k=0;k<82;k++) a[k]+=b[k]-'0'; for(k=0;k<82;k++){ if(a[k]-'0'>=10){ a[k+1]++; a[k]-=10; } } if(a[81]!=0)printf("overflow\n"); else printf("%s\n",a); } } return 0; }
main.c: In function 'main': main.c:11:36: error: expected ';' before ':' token 11 | a[k]=b[k]=0: | ^ | ;
s198877565
p00015
C
#include <stdio.h> #include <string.h> void FuncReverseString(char str, int len); int main(void) { char data1[1000], data2[1000], ans[1000]; int i, j, k, n, a; int p1, p2, flag; scanf("%d", &n); getchar(); /* 改行文字の削除 */ for(k = 0; k < n; k++){ /* 変数の初期化 */ p1 = p2 = flag = a = 0; /* 文字列の初期化 */ for(i = 0; i < 100; i++){ data1[i] = data2[i] = ans[i] = '0'; } /* 文字列に1文字ずつ代入 */ for(i = 0; ; i++){ if(i > 80){ flag = 1; // 80桁を超えるなら"overflow"フラグON } scanf("%c", &data1[i]); if(data1[i] == '\n') break; } data1[i] = '0'; p1 = i; /* 文字列に1文字ずつ代入 */ for(i = 0; ; i++){ if(i > 80){ flag = 1; } scanf("%c", &data2[i]); if(data2[i] == '\n') break; } data2[i] = '0'; p2 = i; /* "overflow"フラグがONなら中断 */ if (flag == 1) { printf("overflow\n"); continue; } /* 反転させて挿入 */ FuncReverseString(data1, p1); FuncReverseString(date2, p2); if (p1 < p2) p1 = p2; /* 1桁ずつ計算する */ for (i = 0; i < p1; i++) { ans[i] = (data1[i] - '0') + (data2[i] - '0'); } /* 桁の繰り上がり */ for (i = 0; i < (p1 - 1); i++) { if (ans[i] >= 10) { ans[i] -= 10; ans[i+1] += 1; } } /* 最高位の繰り上がり */ if (ans[p1-1] > 9) { ans[p1-1] -= 10; ans[p1] = 1; a = 1; } if(a == 1) p1++; if (p1 > 80) { printf("overflow\n"); continue; } for (i = 0; i < p1; i++) { ans[i] += '0'; } for (i = p1-1; i >= 0; i--) { printf("%c", ans[i]); } printf("\n"); } return 0; } void FuncReverseString(char str, int len) { char temp; int i, j; for (i = 0, j = len - 1; j >= 0; i++, j--) { temp[i] = str[j]; } for(i = 0; i < len; i++) { data1[i] = temp[i]; } }
main.c: In function 'main': main.c:53:35: error: passing argument 1 of 'FuncReverseString' makes integer from pointer without a cast [-Wint-conversion] 53 | FuncReverseString(data1, p1); | ^~~~~ | | | char * main.c:4:29: note: expected 'char' but argument is of type 'char *' 4 | void FuncReverseString(char str, int len); | ~~~~~^~~ main.c:55:35: error: 'date2' undeclared (first use in this function); did you mean 'data2'? 55 | FuncReverseString(date2, p2); | ^~~~~ | data2 main.c:55:35: note: each undeclared identifier is reported only once for each function it appears in main.c: In function 'FuncReverseString': main.c:104:21: error: subscripted value is neither array nor pointer nor vector 104 | temp[i] = str[j]; | ^ main.c:104:30: error: subscripted value is neither array nor pointer nor vector 104 | temp[i] = str[j]; | ^ main.c:107:17: error: 'data1' undeclared (first use in this function) 107 | data1[i] = temp[i]; | ^~~~~ main.c:107:32: error: subscripted value is neither array nor pointer nor vector 107 | data1[i] = temp[i]; | ^
s931637747
p00015
C
int main( void ) { int n, i, j, p, q, r, temp, carry, c[81]; scanf( "%d", &n ); for ( i = 0; i < n; i++ ) { scanf( "%s", a ); scanf( "%s", b ); p = strlen( a ); q = strlen( b ); if ( p > 80 || q > 80 ) { printf( "overflow\n" ); } else { r = 0; carry = 0; while ( 1 ) { if ( r >= 80 ) { printf( "overflow\n" ); break; } else if ( p <= 0 && q <= 0 ) { if ( carry == 1 ) { c[r] = 1; r++; } for ( j = r - 1; j >= 0; j-- ) { printf( "%d", c[j] ); } printf( "\n" ); break; } else { c[r] = carry; if ( p > 0 ) { c[r] += a[p-1] - '0'; p--; } if ( q > 0 ) { c[r] += b[q-1] - '0'; q--; } if ( c[r] / 10 == 0 ) { carry = 0; } else { c[r] %= 10; carry = 1; } r++; } } } } return 0; }
main.c: In function 'main': main.c:5:9: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 5 | scanf( "%d", &n ); | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | int main( void ) { main.c:5:9: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 5 | scanf( "%d", &n ); | ^~~~~ main.c:5:9: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:9:30: error: 'a' undeclared (first use in this function) 9 | scanf( "%s", a ); | ^ main.c:9:30: note: each undeclared identifier is reported only once for each function it appears in main.c:10:30: error: 'b' undeclared (first use in this function) 10 | scanf( "%s", b ); | ^ main.c:12:21: error: implicit declaration of function 'strlen' [-Wimplicit-function-declaration] 12 | p = strlen( a ); | ^~~~~~ main.c:1:1: note: include '<string.h>' or provide a declaration of 'strlen' +++ |+#include <string.h> 1 | int main( void ) { main.c:12:21: warning: incompatible implicit declaration of built-in function 'strlen' [-Wbuiltin-declaration-mismatch] 12 | p = strlen( a ); | ^~~~~~ main.c:12:21: note: include '<string.h>' or provide a declaration of 'strlen' main.c:17:25: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 17 | printf( "overflow\n" ); | ^~~~~~ main.c:17:25: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:17:25: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:17:25: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:27:41: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] 27 | printf( "overflow\n" ); | ^~~~~~ main.c:27:41: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:36:49: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] 36 | printf( "%d", c[j] ); | ^~~~~~ main.c:36:49: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:40:41: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] 40 | printf( "\n" ); | ^~~~~~ main.c:40:41: note: include '<stdio.h>' or provide a declaration of 'printf'
s310204311
p00015
C
#include<stdio.h> #include<string.h> int a[1005],b[1005]; int reverse(int *a,int l,int r) { int i,t; for(i=l;i<=r/2;i++) { t=a[i]; a[i]=a[l+r-i]; a[l+r-i]=t; } return 0; } int main() { int n,i,la,lb,lmax,c,tmp; char t; scanf("%d%*c",&n); //霎灘?扈?焚?悟帥謗牙屓霓ヲ隨ヲ while(n--) //隶。邂? { la=0; //貂?峺 lb=0; c=0; memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); while(1) //蟄伜?謨ー蟄? { t=getchar(); if(t>='0'&&t<='9') { a[la]=t-'0'; la++; } else if(t=='\n') { break; } } while(1) { t=getchar(); if(t>='0'&&t<='9') { b[lb]=t-'0'; lb++; } else if(t=='\n') { break; } } if(la>80||lb>80) //霎灘?貅「蜃コ蛻、譁ュ { printf("overflow\n"); return 0; } reverse(a,0,la-1); //蜿榊髄 reverse(b,0,lb-1); lmax=(la>lb)?la:lb; for(i=0;i<=lmax;i++) //螟ァ謨ー蜉?ウ? { tmp=a[i]; a[i]=(tmp+b[i]+c)%10; c=(tmp+b[i]+c)/10; } for(i=lmax;i>=0;i--) //霎灘? { if(a[i]!=0) { tmp=i; break; } } if(lmax+1>80) //霎灘?貅「蜃コ蛻、譁ュ { printf("overflow\n"); return 0; } for(i=tmp;i>=0;i--) { printf("%d",a[i]); } printf("\n"); } return 0; }
main.c: In function 'main': main.c:41:33: error: break statement not within loop or switch 41 | break; | ^~~~~ main.c: At top level: main.c:45:17: error: expected identifier or '(' before 'while' 45 | while(1) | ^~~~~ main.c:59:17: error: expected identifier or '(' before 'if' 59 | if(la>80||lb>80) //霎灘?貅「蜃コ蛻、譁ュ | ^~ main.c:65:27: error: expected ')' before numeric constant 65 | reverse(a,0,la-1); //蜿榊髄 | ^ | ) main.c:66:27: error: expected ')' before numeric constant 66 | reverse(b,0,lb-1); | ^ | ) main.c:68:17: warning: data definition has no type or storage class 68 | lmax=(la>lb)?la:lb; | ^~~~ main.c:68:17: error: type defaults to 'int' in declaration of 'lmax' [-Wimplicit-int] main.c:68:23: error: 'la' undeclared here (not in a function); did you mean 'a'? 68 | lmax=(la>lb)?la:lb; | ^~ | a main.c:68:26: error: 'lb' undeclared here (not in a function); did you mean 'b'? 68 | lmax=(la>lb)?la:lb; | ^~ | b main.c:69:17: error: expected identifier or '(' before 'for' 69 | for(i=0;i<=lmax;i++) //螟ァ謨ー蜉?ウ? { | ^~~ main.c:69:26: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<=' token 69 | for(i=0;i<=lmax;i++) //螟ァ謨ー蜉?ウ? { | ^~ main.c:69:34: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token 69 | for(i=0;i<=lmax;i++) //螟ァ謨ー蜉?ウ? { | ^~ main.c:71:27: error: 'i' undeclared here (not in a function) 71 | a[i]=(tmp+b[i]+c)%10; | ^ main.c:71:25: warning: data definition has no type or storage class 71 | a[i]=(tmp+b[i]+c)%10; | ^ main.c:71:25: error: type defaults to 'int' in declaration of 'a' [-Wimplicit-int] main.c:71:31: error: 'tmp' undeclared here (not in a function) 71 | a[i]=(tmp+b[i]+c)%10; | ^~~ main.c:71:40: error: 'c' undeclared here (not in a function) 71 | a[i]=(tmp+b[i]+c)%10; | ^ main.c:72:25: warning: data definition has no type or storage class 72 | c=(tmp+b[i]+c)/10; | ^ main.c:72:25: error: type defaults to 'int' in declaration of 'c' [-Wimplicit-int] main.c:73:17: error: expected identifier or '(' before '}' token 73 | } | ^ main.c:75:17: error: expected identifier or '(' before 'for' 75 | for(i=lmax;i>=0;i--) //霎灘? | ^~~ main.c:75:29: error: expected '=', ',', ';', 'asm' or '__attribute__' before '>=' token 75 | for(i=lmax;i>=0;i--) //霎灘? | ^~ main.c:75:34: error: expected '=', ',', ';', 'asm' or '__attribute__' before '--' token 75 | for(i=lmax;i>=0;i--) //霎灘? | ^~ main.c:84:17: error: expected identifier or '(' before 'if' 84 | if(lmax+1>80) //霎灘?貅「蜃コ蛻、譁ュ | ^~ main.c:90:17: error: expected identifier or '(' before 'for' 90 | for(i=tmp;i>=0;i--) | ^~~ main.c:90:28: error: expected '=', ',', ';', 'asm' or '__attribute__' before '>=' token 90 | for(i=tmp;i>=0;i--) | ^~ main.c:90:33: error: expected '=', ',', ';', 'asm' or '__attribute__' before '--' token 90 | for(i=tmp;i>=0;i--) | ^~ main.c:94:24: error: expected declaration specifiers or '...' before string constant 94 | printf("\n"); | ^~~~ main.c:95:9: error: expected identifier or '(' before '}' token 95 | } | ^ main.c:96:9: error: expected identifier or '(' before 'return' 96 | return 0; | ^~~~~~ main.c:97:1: error: expected identifier or '(' before '}' token 97 | } | ^
s423625737
p00015
C++
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; int c[100]; void add(char*a, char*b) //鮟倩ョ、a豈巴髟ソ { fill(c,c+100,0); //蜥檎噪蜷?ス咲スョ髮カ int la=strlen(a), lb=strlen(b); for(int i=la,j=lb;i>la-lb&&j>0;i--,j--) // 菫晉蕗c豈泌刈謨ー譛?柄荳イ螟壻ク?ス? { c[i]+=a[i-1]-'0'+b[j-1]-'0'; if(c[i]>9) { c[i]-=10; c[i-1]++; } } for(int i=la-lb;i>0;i--) { c[i]+=a[i-1]-'0'; if(c[i]>9) { c[i]-=10; c[i-1]++; } } if(la==80&&c[0]==1) printf("overflow\n"); else { if(c[0]==0) { for(int i=1;i<=la;i++) printf("%d",c[i]); printf("\n"); } else { for(int i=0;i<=la;i++) printf("%d",c[i]); printf("\n"); } } } int main() { char a[100], b[100]; int n; scanf("%d",&n); while(n--){ scanf("%s%s",a,b); int la = strlen(a), lb = strlen(b); if(la>80 || lb>80) printf("overflow\n"); else if(la>lb) add(a,b); else add(b,a); } return 0; }
a.cc: In function 'void add(char*, char*)': a.cc:14:18: error: 'i' was not declared in this scope 14 | if(c[i]>9) | ^ a.cc: At global scope: a.cc:20:9: error: expected unqualified-id before 'for' 20 | for(int i=la-lb;i>0;i--) | ^~~ a.cc:20:25: error: 'i' does not name a type 20 | for(int i=la-lb;i>0;i--) | ^ a.cc:20:29: error: 'i' does not name a type 20 | for(int i=la-lb;i>0;i--) | ^ a.cc:29:9: error: expected unqualified-id before 'if' 29 | if(la==80&&c[0]==1) printf("overflow\n"); | ^~ a.cc:30:9: error: expected unqualified-id before 'else' 30 | else | ^~~~ a.cc:45:1: error: expected declaration before '}' token 45 | } | ^
s668294483
p00015
C++
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; int c[100]; void add(char*a, char*b) //鮟倩ョ、a豈巴髟ソ { fill(c,c+100,0); //蜥檎噪蜷?ス咲スョ髮カ int la=strlen(a), lb=strlen(b); int i,j; for( i=la,j=lb;i>la-lb&&j>0;i--,j--) // 菫晉蕗c豈泌刈謨ー譛?柄荳イ螟壻ク?ス? { c[i]+=a[i-1]-'0'+b[j-1]-'0'; if(c[i]>9) { c[i]-=10; c[i-1]++; } } for( i=la-lb;i>0;i--) { c[i]+=a[i-1]-'0'; if(c[i]>9) { c[i]-=10; c[i-1]++; } } if(la==80&&c[0]==1) printf("overflow\n"); else { if(c[0]==0) { for( i=1;i<=la;i++) printf("%d",c[i]); printf("\n"); } else { for( i=0;i<=la;i++) printf("%d",c[i]); printf("\n"); } } } int main() { char a[100], b[100]; int n; scanf("%d",&n); while(n--){ scanf("%s%s",a,b); int la = strlen(a), lb = strlen(b); if(la>80 || lb>80) printf("overflow\n"); else if(la>lb) add(a,b); else add(b,a); } return 0; }
a.cc:21:9: error: expected unqualified-id before 'for' 21 | for( i=la-lb;i>0;i--) | ^~~ a.cc:21:22: error: 'i' does not name a type 21 | for( i=la-lb;i>0;i--) | ^ a.cc:21:26: error: 'i' does not name a type 21 | for( i=la-lb;i>0;i--) | ^ a.cc:31:9: error: expected unqualified-id before 'if' 31 | if(la==80&&c[0]==1) printf("overflow\n"); | ^~ a.cc:32:9: error: expected unqualified-id before 'else' 32 | else | ^~~~ a.cc:47:1: error: expected declaration before '}' token 47 | } | ^
s175288335
p00015
C++
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; void add(char*a, char*b, char*c) //鮟倩ョ、a豈巴髟ソ { fill(c,c+100,0); //蜥檎噪蜷?ス咲スョ髮カ int la=strlen(a), lb=strlen(b); int i,j; for( i=la,j=lb;i>la-lb&&j>0;i--,j--) // 菫晉蕗c豈泌刈謨ー譛?柄荳イ螟壻ク?ス? { c[i]+=a[i-1]-'0'+b[j-1]-'0'; if(c[i]>9) { c[i]-=10; c[i-1]++; } } for( i=la-lb;i>0;i--) { c[i]+=a[i-1]-'0'; if(c[i]>9) { c[i]-=10; c[i-1]++; } } if(la==80&&c[0]==1) printf("overflow\n"); else if(c[0]==0) { for( i=1;i<=la;i++) printf("%d",c[i]); printf("\n"); } else { for( i=0;i<=la;i++) printf("%d",c[i]); printf("\n"); } } int c[100]; int main() { char a[100], b[100]; int n; scanf("%d",&n); while(n--){ scanf("%s%s",a,b); int la = strlen(a), lb = strlen(b); if(la>80 || lb>80) printf("overflow\n"); else if(la>lb) add(a,b,c); else add(b,a,c); } return 0; }
a.cc:21:5: error: expected unqualified-id before 'for' 21 | for( i=la-lb;i>0;i--) | ^~~ a.cc:21:18: error: 'i' does not name a type 21 | for( i=la-lb;i>0;i--) | ^ a.cc:21:22: error: 'i' does not name a type 21 | for( i=la-lb;i>0;i--) | ^ a.cc:31:5: error: expected unqualified-id before 'if' 31 | if(la==80&&c[0]==1) | ^~ a.cc:33:5: error: expected unqualified-id before 'else' 33 | else if(c[0]==0) | ^~~~ a.cc:39:13: error: expected unqualified-id before 'else' 39 | else | ^~~~ a.cc:46:1: error: expected declaration before '}' token 46 | } | ^ a.cc: In function 'int main()': a.cc:61:17: error: cannot convert 'int*' to 'char*' 61 | add(a,b,c); | ^ | | | int* a.cc:8:31: note: initializing argument 3 of 'void add(char*, char*, char*)' 8 | void add(char*a, char*b, char*c) //鮟倩ョ、a豈巴髟ソ | ~~~~~^ a.cc:62:18: error: cannot convert 'int*' to 'char*' 62 | else add(b,a,c); | ^ | | | int* a.cc:8:31: note: initializing argument 3 of 'void add(char*, char*, char*)' 8 | void add(char*a, char*b, char*c) //鮟倩ョ、a豈巴髟ソ | ~~~~~^
s054002170
p00015
C++
#include<iostream> int main(){ int n; cin>>n; while(n--){ long long int a,b; cin>>a>>b; cout<<a+b<<endl; } }
a.cc: In function 'int main()': a.cc:4:1: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 4 | cin>>n; | ^~~ | std::cin In file included from a.cc:1: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:8:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 8 | cout<<a+b<<endl; | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ a.cc:8:16: error: 'endl' was not declared in this scope; did you mean 'std::endl'? 8 | cout<<a+b<<endl; | ^~~~ | std::endl In file included from /usr/include/c++/14/iostream:41: /usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here 744 | endl(basic_ostream<_CharT, _Traits>& __os) | ^~~~
s335751967
p00015
C++
#include <iostream> #include <string> #include <algorithm> using namespace std; #define MAX_ORDER 80 void alignOrder(std::string& input1, std::string& input2); int myAtoi(const char c); void addTwoInputs(const std::string& input1, const std::string& input2, std::string& output); bool overflowCheck(const std::string& output); int main(void) { int n; std::string input1, input2; std::string output; std::cin >> n; for (int i = 0; i < n; i++) { std::cin >> input1; std::cin >> input2; alignOrder(input1, input2); addTwoInputs(input1, input2, output); if (overflowCheck(output)) { std::cout << output << std::endl; } else { std::cout << "overflow" << std::endl; } } return 0; } void alignOrder(std::string& input1, std::string& input2) { if (input1.size() == input2.size()) { return; } if (input1.size() < input2.size()) { std::swap(input1, input2); } int distance = input1.size() - input2.size(); for (int i = 0; i < distance; i++) { input2.insert(0, "0"); } return; } int myAtoi(const char c) { return c - '0'; } void addTwoInputs(const std::string& input1, const std::string& input2, std::string& output) { int outputOrder = input1.size() + 1; output.resize(outputOrder); bool advance = false; for (int i = outputOrder - 2; i >= 0; i--) { int num1 = myAtoi(input1[i]); int num2 = myAtoi(input2[i]); int sum = num1 + num2; if (advance) { sum++; } char sumStr[10]; itoa(sum, sumStr, 10); if (sumStr[1] == '\0') { output[i + 1] = sumStr[0]; advance = false; } else { output[i + 1] = sumStr[1]; advance = true; } if (i == 0) { if (advance) { output[0] = '1'; } else { output = output.substr(1); } } } } bool overflowCheck(const std::string& output) { if (output.size() > MAX_ORDER) { return false; } return true; }
a.cc: In function 'void addTwoInputs(const std::string&, const std::string&, std::string&)': a.cc:73:5: error: 'itoa' was not declared in this scope 73 | itoa(sum, sumStr, 10); | ^~~~
s084121499
p00015
C++
#include <iostream> #include <string> #include <algorithm> #include <stdlib.h> using namespace std; #define MAX_ORDER 80 void alignOrder(std::string& input1, std::string& input2); int myAtoi(const char c); void addTwoInputs(const std::string& input1, const std::string& input2, std::string& output); bool overflowCheck(const std::string& output); int main(void) { int n; std::string input1, input2; std::string output; std::cin >> n; for (int i = 0; i < n; i++) { std::cin >> input1; std::cin >> input2; alignOrder(input1, input2); addTwoInputs(input1, input2, output); if (overflowCheck(output)) { std::cout << output << std::endl; } else { std::cout << "overflow" << std::endl; } } return 0; } void alignOrder(std::string& input1, std::string& input2) { if (input1.size() == input2.size()) { return; } if (input1.size() < input2.size()) { std::swap(input1, input2); } int distance = input1.size() - input2.size(); for (int i = 0; i < distance; i++) { input2.insert(0, "0"); } return; } int myAtoi(const char c) { return c - '0'; } void addTwoInputs(const std::string& input1, const std::string& input2, std::string& output) { int outputOrder = input1.size() + 1; output.resize(outputOrder); bool advance = false; for (int i = outputOrder - 2; i >= 0; i--) { int num1 = myAtoi(input1[i]); int num2 = myAtoi(input2[i]); int sum = num1 + num2; if (advance) { sum++; } char sumStr[10]; itoa(sum, sumStr, 10); if (sumStr[1] == '\0') { output[i + 1] = sumStr[0]; advance = false; } else { output[i + 1] = sumStr[1]; advance = true; } if (i == 0) { if (advance) { output[0] = '1'; } else { output = output.substr(1); } } } } bool overflowCheck(const std::string& output) { if (output.size() > MAX_ORDER) { return false; } return true; }
a.cc: In function 'void addTwoInputs(const std::string&, const std::string&, std::string&)': a.cc:74:5: error: 'itoa' was not declared in this scope 74 | itoa(sum, sumStr, 10); | ^~~~
s236055141
p00015
C++
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ int T; cin >> T; while(T--){ //char s[100] = "abc"; string a,b; cin >> a >> b; if(a==0&&b==0){cout<<0<<endl;continue;} reverse(a.begin(),a.end()); reverse(b.begin(),b.end()); while( a.size() < 100 ) a += "0"; while( b.size() < 100 ) b += "0"; string ans = ""; int carry = 0; for(int i = 0 ; i < 100 ; i++){ int d = (a[i]-'0') + (b[i]-'0') + carry; ans += d % 10 + '0'; carry = d / 10; } reverse(ans.begin(),ans.end()); if(ans.find_first_not_of('0')<20){ cout << "overflow" << endl; continue; } ans = ans.substr(ans.find_first_not_of('0') ); cout << ans << endl; } return 0; }
a.cc: In function 'int main()': a.cc:13:21: error: no match for 'operator==' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'int') 13 | if(a==0&&b==0){cout<<0<<endl;continue;} | ~^~~ | | | | | int | std::string {aka std::__cxx11::basic_string<char>} In file included from /usr/include/c++/14/iosfwd:42, from /usr/include/c++/14/ios:40, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)' 192 | operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/postypes.h:192:5: note: template argument deduction/substitution failed: a.cc:13:23: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::fpos<_StateT>' 13 | if(a==0&&b==0){cout<<0<<endl;continue;} | ^ In file included from /usr/include/c++/14/string:43, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44: /usr/include/c++/14/bits/allocator.h:235:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const allocator<_CharT>&, const allocator<_T2>&)' 235 | operator==(const allocator<_T1>&, const allocator<_T2>&) | ^~~~~~~~ /usr/include/c++/14/bits/allocator.h:235:5: note: template argument deduction/substitution failed: a.cc:13:23: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::allocator<_CharT>' 13 | if(a==0&&b==0){cout<<0<<endl;continue;} | ^ In file included from /usr/include/c++/14/string:48: /usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 441 | operator==(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:441:5: note: template argument deduction/substitution failed: a.cc:13:23: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 13 | if(a==0&&b==0){cout<<0<<endl;continue;} | ^ /usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 486 | operator==(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:486:5: note: template argument deduction/substitution failed: a.cc:13:23: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 13 | if(a==0&&b==0){cout<<0<<endl;continue;} | ^ /usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1667 | operator==(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1667:5: note: template argument deduction/substitution failed: a.cc:13:23: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 13 | if(a==0&&b==0){cout<<0<<endl;continue;} | ^ /usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1737 | operator==(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1737:5: note: template argument deduction/substitution failed: a.cc:13:23: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 13 | if(a==0&&b==0){cout<<0<<endl;continue;} | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/string:51: /usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1033 | operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1033:5: note: template argument deduction/substitution failed: a.cc:13:23: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::pair<_T1, _T2>' 13 | if(a==0&&b==0){cout<<0<<endl;continue;} | ^ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:629:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 629 | operator==(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:629:5: note: template argument deduction/substitution failed: a.cc:13:23: note: 'std::__cxx11::basic_string<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 13 | if(a==0&&b==0){cout<<0<<endl;continue;} | ^ /usr/include/c++/14/string_view:637:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 637 | operator==(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:637:5: note: template argument deduction/substitution failed: a.cc:13:23: note: 'std::__cxx11::basic_string<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 13 | if(a==0&&b==0){cout<<0<<endl;continue;} | ^ /usr/include/c++/14/string_view:644:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 644 | operator==(__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:644:5: note: template argument deduction/substitution failed: a.cc:13:23: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int' 13 | if(a==0&&b==0){cout<<0<<endl;continue;} | ^ /usr/include/c++/14/bits/basic_string.h:3755:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3755 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3755:5: note: template argument deduction/substitution failed: a.cc:13:23: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int' 13 | if(a==0&&b==0){cout<<0<<endl;continue;} | ^ /usr/include/c++/14/bits/basic_string.h:3772:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3772 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3772:5: note: template argument deduction/substitution failed: a.cc:13:23: note: mismatched types 'const _CharT*' and 'int' 13 | if(a==0&&b==0){cout<<0<<endl;continue;} | ^ /usr/include/c++/14/bits/basic_string.h:3819:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3819 | operator==(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3819:5: note: template argument deduction/substitution failed: a.cc:13:23: note: mismatched types 'const _CharT*' and 'std::__cxx11::basic_string<char>' 13 | if(a==0&&b==0){cout<<0<<endl;continue;} | ^ In file included from /usr/include/c++/14/bits/memory_resource.h:47, from /usr/include/c++/14/string:68: /usr/include/c++/14/tuple:2558:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator==(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)' 2558 | operator==(const tuple<_TElements...>& __t, | ^~~~~~~~ /usr/include/c++/14/tuple:2558:5: note: template argument deduction/substitution failed: a.cc:13:23: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::tuple<_UTypes ...>' 13 | if(a==0&&b==0){cout<<0<<endl;continue;} | ^ In file included from /usr/include/c++/14/bits/locale_facets.h:48, from /usr/include/c++/14/bits/basic_ios.h:37, from /usr/include/c++/14/ios:46: /usr/include/c++/14/bits/streambuf_iterator.h:234:5: note: candidate: 'template<class _CharT, class _Traits> bool std::operator==(const istreambuf_iterator<_CharT, _Traits>&, const istreambuf_iterator<_CharT, _Traits>&)' 234 | operator==(const istreambuf_iterator<_CharT, _Traits>& __a, | ^~~~~~~~ /usr/include/c++/14/bits/streamb
s150778579
p00015
C++
#include <iostream> #include <string> using namespace std; int main() { int N; cin >> N; for (; N > 0; --N) { int a[80] = {}, b[80] = {}, sum[80] = {}; bool co = false; string s, t; cin >> s >> t; for (int i = 0; i < s.length(); ++i) a[i] = (int)(s[i] - '0'); for (int i = 0; i < t.length(); ++i) b[i] = (int)(t[i] - '0'); for (int i = 0; i < 80; ++i) { co = ((co?1:0)+a[i]+b[i]) >= 10; sum[i] = ((co?1:0)+a[i]+b[i])%10; } if (co) cout << "overflow" << endl; else { bool fz = true; for (int i = 79; i >= 0; --i) if (fz && sum[i] != 0) {fz = false;} if (!fz) cout << sum[i]; } cout << endl; } return 0; }
a.cc: In function 'int main()': a.cc:24:22: error: 'i' was not declared in this scope 24 | if (!fz) cout << sum[i]; | ^
s615522677
p00015
C++
#include<stdio.h> #define STR_MAX 80 #define ASCII_BIAS 48 char h_adder(char n1, char n2, char *n3, char carry) { char result = n1 + n2 + carry; if(result<10){ *n3 = result + ASCII_BIAS; return 0; } else{ *n3 = result-10+ASCII_BIAS; return 1; } } int main(void) { int i, j; int dataset; char in[2][STR_MAX+2], out[STR_MAX+2], result[STR_MAX+2]; int len_in[2], idx_min, idx_max, lmin, lmax, lout, dif; char carry; scanf("%d\n", &dataset); for(i=0;i<dataset;i++){ fgets(in[0], sizeof in[0], stdin); rewind(stdin); fgets(in[1], sizeof in[1], stdin); rewind(stdin); len_in[0] = strlen(in[0])-1; len_in[1] = strlen(in[1])-1; // check # of digits if(in[0][len_in[0]]!='\n' || in[1][len_in[1]]!='\n'){ printf("overflow\n"); continue; } in[0][len_in[0]] = '\0'; in[1][len_in[1]] = '\0'; idx_min = (len_in[0]>len_in[1]) ? 1 : 0; // idx of shoter str idx_max = (idx_min + 1) & 1; // idx of longer str lmin = len_in[idx_min]-1; lmax = len_in[idx_max]-1; dif = (len_in[0]>len_in[1]) ? len_in[0]-len_in[1] : len_in[1]-len_in[0]; // difference in digits // execute addition carry = 0; for(j=0;j<lmin+1;j++){ carry = h_adder(in[idx_min][lmin-j]-ASCII_BIAS, in[idx_max][lmin-j+dif]-ASCII_BIAS, &out[j+1], carry); } for(j=lmin+1;j<lmax+1;j++){ carry = h_adder(0, in[idx_max][lmin-j+dif]-ASCII_BIAS, &out[j+1], carry); } // if carry is 0, validate overflow if(carry==1){ if(lmax==STR_MAX-1){ printf("overflow\n"); continue; } } lout = carry ? lmax+2 : lmax+1; out[lmax+2] = carry ? 1+ASCII_BIAS : 0+ASCII_BIAS; // if overflow does not occur, addition succeeded out[0] = '\0'; for(j=0;j<lout+1;j++){ result[j] = out[lout-j]; } printf("%s\n", result); } }
a.cc: In function 'int main()': a.cc:27:17: error: 'strlen' was not declared in this scope 27 | len_in[0] = strlen(in[0])-1; len_in[1] = strlen(in[1])-1; | ^~~~~~ a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include<stdio.h> +++ |+#include <cstring> 2 |
s675895113
p00015
C++
#include <iostream> #include <string> #include <fstream> using namespace std; #define MAX_INT_LENGTH 80 //large integer upto 80 digits struct largeInt{ int vals[MAX_INT_LENGTH]; // MAX_INT_LENGTH digits }; void toLargeInt(string str, largeInt &lv){ int start = MAX_INT_LENGTH-str.length(); for (int i = 0; i < MAX_INT_LENGTH; i++){ if (i >= start) lv.vals[i] = (str[i-start] - '0'); else lv.vals[i] = 0; } } largeInt addLargeInt(const largeInt &lv1, const largeInt &lv2){ largeInt sum; int carry = 0; for (int i = MAX_INT_LENGTH-1; i >= 0; i--){ int sub_sum = lv1.vals[i] + lv2.vals[i] + carry; sum.vals[i] = sub_sum % 10; carry = sub_sum / 10; } return sum; } string toString(const largeInt &v){ string str(MAX_INT_LENGTH,'0'); for (int i = 0; i < MAX_INT_LENGTH; i++) str[i] = v.vals[i] + '0'; return str; } int main() { //ifstream cin("input.txt"); // input data int n; cin >> n; for (int i = 0; i < n; i++){ string v1,v2; cin >> v1 >> v2; largeInt lv1, lv2; if (lv1.length()>MAX_INT_LENGTH || lv2.length()>MAX_INT_LENGTH){ cout << "overflow" << endl; continue; } toLargeInt(v1,lv1); toLargeInt(v2,lv2); largeInt sum = addLargeInt(lv1,lv2); cout << toString(sum) << endl; } return 0; }
a.cc: In function 'int main()': a.cc:53:17: error: 'struct largeInt' has no member named 'length' 53 | if (lv1.length()>MAX_INT_LENGTH || lv2.length()>MAX_INT_LENGTH){ | ^~~~~~ a.cc:53:48: error: 'struct largeInt' has no member named 'length' 53 | if (lv1.length()>MAX_INT_LENGTH || lv2.length()>MAX_INT_LENGTH){ | ^~~~~~
s364901472
p00015
C++
#include <iostream> #include <string> #include <sstraem> #include <fstream> using namespace std; #define MAX_INT_LENGTH 80 //large integer upto 80 digits struct largeInt{ int vals[MAX_INT_LENGTH]; // MAX_INT_LENGTH digits }; void toLargeInt(string str, largeInt &lv){ int start = MAX_INT_LENGTH-str.length(); for (int i = 0; i < MAX_INT_LENGTH; i++){ if (i >= start) lv.vals[i] = (str[i-start] - '0'); else lv.vals[i] = 0; } } largeInt addLargeInt(const largeInt &lv1, const largeInt &lv2){ largeInt sum; int carry = 0; for (int i = MAX_INT_LENGTH-1; i >= 0; i--){ int sub_sum = lv1.vals[i] + lv2.vals[i] + carry; sum.vals[i] = sub_sum % 10; carry = sub_sum / 10; } return sum; } string toString(const largeInt &v){ stringstream ss; int i = 0; while (i < MAX_INT_LENGTH-1 && v.vals[i]==0) i++; while (i < MAX_INT_LENGTH){ str[i] = v.vals[i] + '0'; i++; } return str; } int main() { ifstream cin("input.txt"); // input data int n; cin >> n; for (int i = 0; i < n; i++){ string v1,v2; cin >> v1 >> v2; largeInt lv1, lv2; if (v1.length()>MAX_INT_LENGTH || v2.length()>MAX_INT_LENGTH){ cout << "overflow" << endl; continue; } toLargeInt(v1,lv1); toLargeInt(v2,lv2); largeInt sum = addLargeInt(lv1,lv2); cout << toString(sum) << endl; } return 0; }
a.cc:3:10: fatal error: sstraem: No such file or directory 3 | #include <sstraem> | ^~~~~~~~~ compilation terminated.
s715953376
p00015
C++
#include <iostream> #include <string> #include <sstraem> #include <fstream> using namespace std; #define MAX_INT_LENGTH 80 //large integer upto 80 digits struct largeInt{ int vals[MAX_INT_LENGTH]; // MAX_INT_LENGTH digits }; void toLargeInt(string str, largeInt &lv){ int start = MAX_INT_LENGTH-str.length(); for (int i = 0; i < MAX_INT_LENGTH; i++){ if (i >= start) lv.vals[i] = (str[i-start] - '0'); else lv.vals[i] = 0; } } largeInt addLargeInt(const largeInt &lv1, const largeInt &lv2){ largeInt sum; int carry = 0; for (int i = MAX_INT_LENGTH-1; i >= 0; i--){ int sub_sum = lv1.vals[i] + lv2.vals[i] + carry; sum.vals[i] = sub_sum % 10; carry = sub_sum / 10; } return sum; } string toString(const largeInt &v){ stringstream ss; int i = 0; while (i < MAX_INT_LENGTH-1 && v.vals[i]==0) i++; while (i < MAX_INT_LENGTH){ str[i] = v.vals[i] + '0'; i++; } return str; } int main() { //ifstream cin("input.txt"); // input data int n; cin >> n; for (int i = 0; i < n; i++){ string v1,v2; cin >> v1 >> v2; largeInt lv1, lv2; if (v1.length()>MAX_INT_LENGTH || v2.length()>MAX_INT_LENGTH){ cout << "overflow" << endl; continue; } toLargeInt(v1,lv1); toLargeInt(v2,lv2); largeInt sum = addLargeInt(lv1,lv2); cout << toString(sum) << endl; } return 0; }
a.cc:3:10: fatal error: sstraem: No such file or directory 3 | #include <sstraem> | ^~~~~~~~~ compilation terminated.
s537940500
p00015
C++
#include <iostream> #include <string> #include <sstraem> #include <fstream> using namespace std; #define MAX_INT_LENGTH 80 //large integer upto 80 digits struct largeInt{ int vals[MAX_INT_LENGTH]; // MAX_INT_LENGTH digits }; void toLargeInt(string str, largeInt &lv){ int start = MAX_INT_LENGTH-str.length(); for (int i = 0; i < MAX_INT_LENGTH; i++){ if (i >= start) lv.vals[i] = (str[i-start] - '0'); else lv.vals[i] = 0; } } largeInt addLargeInt(const largeInt &lv1, const largeInt &lv2){ largeInt sum; int carry = 0; for (int i = MAX_INT_LENGTH-1; i >= 0; i--){ int sub_sum = lv1.vals[i] + lv2.vals[i] + carry; sum.vals[i] = sub_sum % 10; carry = sub_sum / 10; } return sum; } string toString(const largeInt &v){ stringstream ss; int i = 0; while (i < MAX_INT_LENGTH-1 && v.vals[i]==0) i++; while (i < MAX_INT_LENGTH){ ss << v.vals[i] + '0'; i++; } return ss.str(); } int main() { //ifstream cin("input.txt"); // input data int n; cin >> n; for (int i = 0; i < n; i++){ string v1,v2; cin >> v1 >> v2; largeInt lv1, lv2; if (v1.length()>MAX_INT_LENGTH || v2.length()>MAX_INT_LENGTH){ cout << "overflow" << endl; continue; } toLargeInt(v1,lv1); toLargeInt(v2,lv2); largeInt sum = addLargeInt(lv1,lv2); cout << toString(sum) << endl; } return 0; }
a.cc:3:10: fatal error: sstraem: No such file or directory 3 | #include <sstraem> | ^~~~~~~~~ compilation terminated.
s741188097
p00015
C++
int main(){ int n; cin>>n; rep(j,n){ int x[100]={},y[100]={}; string a,b; cin>>a>>b; if(a.size()>80 || b.size()>80){cout<<"overflow"<<endl;return 0;} else{ for(int i=a.size()-1;i>=0;i--){ x[a.size()-1-i]=a[i]-'0'; } for(int i=b.size()-1;i>=0;i--){ y[b.size()-1-i]=b[i]-'0'; } int ans[100]={}; for(int i=0;i<80;i++){ ans[i]+=x[i]+y[i]; ans[i+1]+=ans[i]/10; ans[i]-=ans[i]/10*10; } if(ans[80]!=0)cout<<"overflow"<<endl; else{ bool flag=false; for(int i=79;i>=0;i--){ if(ans[i]!=0)flag=true; if(flag||i==0)cout<<ans[i]; } } cout<<endl; } } return 0; }
a.cc: In function 'int main()': a.cc:5:5: error: 'cin' was not declared in this scope 5 | cin>>n; | ^~~ a.cc:7:9: error: 'j' was not declared in this scope 7 | rep(j,n){ | ^ a.cc:7:5: error: 'rep' was not declared in this scope 7 | rep(j,n){ | ^~~
s458424727
p00015
C++
#include <iostream> #include <string> #include <algorithm> using namespace std; int main(){ int n; string s1,s2,ans; cin >> n; for(int i=0; i<n; i++){ cin >> s1; cin >> s2; int m = max(s1.size(),s2.size()); while(m>s1.size()) '0' + s1; while(m>s2.size()) '0' + s2; int carry = 0; for(int j=m-1; m>=0; m--){ char ch = ((s1[m]-'0') + (s2[m]-'0') + carry)%10 + '0'; carry = ((s1[m]-'0') + (s2[m]-'0') + carry)/10; ans.append(ch); } if(carry) ans.append(carry+'0'); reverse(ans.begin(),ans.end()); //頭の0を削除していく while(ans.size()>1 && ans[0] == '0') ans.erase(ans.begin()); if(ans.size() > 80) cout << 'overflow' << endl; cout << ans << endl; } return 0; }
a.cc:29:33: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes 29 | if(ans.size() > 80) cout << 'overflow' << endl; | ^~~~~~~~~~ a.cc: In function 'int main()': a.cc:15:30: warning: ignoring return value of 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&) [with _CharT = char; _Traits = char_traits<char>; _Alloc = allocator<char>]', declared with attribute 'nodiscard' [-Wunused-result] 15 | while(m>s1.size()) '0' + s1; | ^~ In file included from /usr/include/c++/14/string:54, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/basic_string.h:3635:5: note: declared here 3635 | operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs) | ^~~~~~~~ a.cc:16:30: warning: ignoring return value of 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&) [with _CharT = char; _Traits = char_traits<char>; _Alloc = allocator<char>]', declared with attribute 'nodiscard' [-Wunused-result] 16 | while(m>s2.size()) '0' + s2; | ^~ /usr/include/c++/14/bits/basic_string.h:3635:5: note: declared here 3635 | operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs) | ^~~~~~~~ a.cc:22:17: error: no matching function for call to 'std::__cxx11::basic_string<char>::append(char&)' 22 | ans.append(ch); | ~~~~~~~~~~^~~~ /usr/include/c++/14/bits/basic_string.h:1480:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' (near match) 1480 | append(const _CharT* __s) | ^~~~~~ /usr/include/c++/14/bits/basic_string.h:1480:7: note: conversion of argument 1 would be ill-formed: a.cc:22:18: error: invalid conversion from 'char' to 'const char*' [-fpermissive] 22 | ans.append(ch); | ^~ | | | char /usr/include/c++/14/bits/basic_string.h:1529:9: note: candidate: 'template<class _InputIterator, class> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(_InputIterator, _InputIterator) [with <template-parameter-2-2> = _InputIterator; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' 1529 | append(_InputIterator __first, _InputIterator __last) | ^~~~~~ /usr/include/c++/14/bits/basic_string.h:1529:9: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/basic_string.h:1541:9: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' 1541 | append(const _Tp& __svt) | ^~~~~~ /usr/include/c++/14/bits/basic_string.h:1541:9: note: template argument deduction/substitution failed: In file included from /usr/include/c++/14/bits/move.h:37, from /usr/include/c++/14/bits/exception_ptr.h:41, from /usr/include/c++/14/exception:166, from /usr/include/c++/14/ios:41: /usr/include/c++/14/type_traits: In substitution of 'template<bool _Cond, class _Tp> using std::enable_if_t = typename std::enable_if::type [with bool _Cond = false; _Tp = std::__cxx11::basic_string<char>&]': /usr/include/c++/14/bits/basic_string.h:149:8: required by substitution of 'template<class _CharT, class _Traits, class _Alloc> template<class _Tp, class _Res> using std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv = std::enable_if_t<((bool)std::__and_<std::is_convertible<const _Tp&, std::basic_string_view<_CharT, _Traits> >, std::__not_<std::is_convertible<const _Tp*, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>*> >, std::__not_<std::is_convertible<const _Tp&, const _CharT*> > >::value), _Res> [with _Tp = char; _Res = std::__cxx11::basic_string<char>&; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' 149 | using _If_sv = enable_if_t< | ^~~~~~ /usr/include/c++/14/bits/basic_string.h:1541:9: required by substitution of 'template<class _Tp> std::__cxx11::basic_string<char>::_If_sv<_Tp, std::__cxx11::basic_string<char>&> std::__cxx11::basic_string<char>::append(const _Tp&) [with _Tp = char]' 1541 | append(const _Tp& __svt) | ^~~~~~ a.cc:22:17: required from here 22 | ans.append(ch); | ~~~~~~~~~~^~~~ /usr/include/c++/14/type_traits:2711:11: error: no type named 'type' in 'struct std::enable_if<false, std::__cxx11::basic_string<char>&>' 2711 | using enable_if_t = typename enable_if<_Cond, _Tp>::type; | ^~~~~~~~~~~ /usr/include/c++/14/bits/basic_string.h:1557:9: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(const _Tp&, size_type, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' 1557 | append(const _Tp& __svt, size_type __pos, size_type __n = npos) | ^~~~~~ /usr/include/c++/14/bits/basic_string.h:1557:9: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/basic_string.h:1435:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' 1435 | append(const basic_string& __str) | ^~~~~~ /usr/include/c++/14/bits/basic_string.h:1435:34: note: no known conversion for argument 1 from 'char' to 'const std::__cxx11::basic_string<char>&' 1435 | append(const basic_string& __str) | ~~~~~~~~~~~~~~~~~~~~^~~~~ /usr/include/c++/14/bits/basic_string.h:1453:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, size_type, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' 1453 | append(const basic_string& __str, size_type __pos, size_type __n = npos) | ^~~~~~ /usr/include/c++/14/bits/basic_string.h:1453:7: note: candidate expects 3 arguments, 1 provided /usr/include/c++/14/bits/basic_string.h:1466:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(const _CharT*, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' 1466 | append(const _CharT* __s, size_type __n) | ^~~~~~ /usr/include/c++/14/bits/basic_string.h:1466:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/basic_string.h:1498:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(size_type, _CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' 1498 | append(size_type __n, _CharT __c) | ^~~~~~ /usr/include/c++/14/bits/basic_string.h:1498:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/basic_string.h:1509:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(std::initializer_list<_Tp>) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' 1509 | append(initializer_list<_CharT> __l) | ^~~~~~ /usr/include/c++/14/bits/basic_string.h:1509:39: note: no known conversion for argument 1 from 'char' to 'std::initializer_list<char>' 1509 | append(initializer_list<_CharT> __l) | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~ a.cc:24:25: error: no matching function for call to 'std::__cxx11::basic_string<char>::append(int)' 24 | if(carry) ans.append(carry+'0'); | ~~~~~~~~~~^~~~~~~~~~~ /usr/include/c++/14/bits/basic_string.h:1480:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' (near match) 1480 | append(const _CharT* __s) | ^~~~~~ /usr/include/c++/14/bits/basic_string.h:1480:7: note: conversion of argument 1 would be ill-formed: a.cc:24:31: error: invalid conversion from 'int' to 'const char*' [-fpermissive] 24 | if(carry) ans.append(carry+'0'); | ~~~~~^~~~ | | | int /usr/include/c++/14/bits/basic_string.h:1529:9: note: candidate: 'template<class _InputIterator, class> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(_InputIterator, _InputIterator) [with <template-parameter-2-2> = _InputIterator; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' 1529 | append(_InputIterator __first, _InputIterator __last)
s390276552
p00015
C++
import sys n = int(input()) for i in range(n): a = int(input()) b = int(input()) if a + b >= 10**80: print ("overflow") else: print(a + b)
a.cc:1:1: error: 'import' does not name a type 1 | import sys | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
s664286918
p00015
C++
#include <iostream> #include <boost/multiprecision/cpp_int.hpp> using namespace boost::multiprecision; int main() { unsigned int a; cpp_int b, c; std::cin >> a; for (unsigned int i = 0; i < a * 2; ++i) { if (i % 2 == 0) { std::cin >> b; } else { std::cin >> c; std::cout << b + c << std::endl; } } }
a.cc:2:10: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory 2 | #include <boost/multiprecision/cpp_int.hpp> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated.
s700188172
p00015
C++
#include <iostream> //#include <boost/multiprecision/cpp_int.hpp> using namespace boost::multiprecision; int main() { unsigned int a; cpp_int b, c; std::cin >> a; for (unsigned int i = 0; i < a * 2; ++i) { if (i % 2 == 0) { std::cin >> b; } else { std::cin >> c; std::cout << b + c << std::endl; } } }
a.cc:4:17: error: 'boost' has not been declared 4 | using namespace boost::multiprecision; | ^~~~~ a.cc:4:24: error: 'multiprecision' is not a namespace-name 4 | using namespace boost::multiprecision; | ^~~~~~~~~~~~~~ a.cc: In function 'int main()': a.cc:9:3: error: 'cpp_int' was not declared in this scope; did you mean 'u_int'? 9 | cpp_int b, c; | ^~~~~~~ | u_int a.cc:13:19: error: 'b' was not declared in this scope 13 | std::cin >> b; | ^ a.cc:15:19: error: 'c' was not declared in this scope 15 | std::cin >> c; | ^ a.cc:16:20: error: 'b' was not declared in this scope 16 | std::cout << b + c << std::endl; | ^
s524479881
p00015
C++
#include<iostream> #include<string> #include<algorithm> using namespace std; int main(){ string a,b,c; int n; cin>>n; for(int fjal=0;fjal<n;fjal++){ cin>>a>>b; c.clear(); if(a.size()<b.size())swap(a,b); int as=a.size();] while(as!=b.size())b="0"+b; //cout<<a<<" "<<b; bool kuri=false; for(int i=as-1;i>=0;i--){ int _a=a[i]-'0',_b=b[i]-'0',ans=_a+_b; if(kuri)ans++; if(ans>=10){ kuri=true; ans-=10; } else {kuri=false;} //cout<<ans<<" "<<i; c.push_back(ans+'0'); } if(kuri)c.push_back('1'); string ans; if(c.size()<80){for(int i=c.size()-1;i>=0;i--)ans.push_back(c[i]); cout<<ans<<endl; } else cout<<"overflow"<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:13:25: error: expected primary-expression before ']' token 13 | int as=a.size();] | ^
s885280258
p00015
C++
import java.util.Scanner; public class Main { int SIZE = 80; int[] ans; void run() { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); for (int l = 0; l < n; l++) { // 80ケタの数字は扱えないので文字列に char[] a = sc.next().toCharArray(); char[] b = sc.next().toCharArray(); // 入力が80ケタを超える if (a.length > SIZE || b.length > SIZE) { System.out.println("overflow"); continue; } // 文字列⇒配列に int[] x = new int[a.length]; int[] y = new int[b.length]; for (int i = 0; i < a.length; i++) { x[i] = a[i] - '0'; } for (int i = 0; i < b.length; i++) { y[i] = b[i] - '0'; } // 大きい桁数+1だけ答えの配列をとる if (x.length >= y.length) { ans = new int[x.length + 1]; } else { ans = new int[y.length + 1]; } int i = x.length - 1; int j = y.length - 1; int k = ans.length - 1; int count = 0; boolean flag = false; // 同じ桁数の計算 while (i >= 0 && j >= 0) { count++; ans[k] += (x[i] + y[j]); // 繰り上がり処理 if (ans[k] >= 10) { if (count < SIZE) { ans[k - 1] = 1; ans[k] -= 10; } else { flag = true; } } i--; j--; k--; } if (i > j) { while (i >= 0) { count++; ans[k] += x[i]; // 繰り上がり処理 if (ans[k] >= 10) { if (count < SIZE) { ans[k - 1] = 1; ans[k] -= 10; } else { flag = true; } } k--; i--; } } else { while (j >= 0) { count++; ans[k] += y[j]; // 繰り上がり処理 if (ans[k] >= 10) { if (count < SIZE) { ans[k - 1] = 1; ans[k] -= 10; } else { flag = true; } } k--; j--; } } if (flag) { System.out.println("overflow"); continue; } for (int m = 0; m < ans.length; m++) { if (m == 0 && ans[m] == 0) { continue; } System.out.print(ans[m]); } System.out.println(); } sc.close(); } // void run1() { // Scanner sc = new Scanner(System.in); // int n = sc.nextInt(); // // for (int k = 0; k < n; k++) { // // char[] a = new char[SIZE]; // // char[] b = new char[SIZE]; // // int[] x = new int[SIZE]; // int[] y = new int[SIZE]; // int[] ans = new int[SIZE]; // // char[] a = sc.next().toCharArray(); // char[] b = sc.next().toCharArray(); // // if (a.length > 80 || b.length > 80) { // System.out.println("overflow"); // continue; // } // // for (int i = 0; i < a.length; i++) { // x[i] = a[i] - '0'; // } // // for (int i = 0; i < b.length; i++) { // y[i] = b[i] - '0'; // } // // int i = a.length - 1; // int j = b.length - 1; // int l = 0; // boolean flag = true; // // while (i >= 0 || j >= 0) { // if (j < 0) { // while (i >= 0) { // ans[l] += x[i]; // if (ans[l] >= 10) { // ans[l] -= 10; // if (l + 1 >= 80) { // flag = false; // break; // } // ans[l + 1] = 1; // } // l++; // i--; // } // break; // } // // if (i < 0) { // while (j >= 0) { // ans[l] += y[j]; // if (ans[l] >= 10) { // ans[l] -= 10; // if (l + 1 >= 80) { // flag = false; // break; // } // ans[l + 1] = 1; // } // l++; // j--; // } // break; // } // // ans[l] += (x[i] + y[j]); // if (ans[l] >= 10) { // ans[l] -= 10; // if (l + 1 >= 80) { // flag = false; // break; // } // ans[l + 1] = 1; // } // l++; // i--; // j--; // } // // if (!flag) { // System.out.println("overflow"); // } // else { // if (ans[l] == 1) { // l++; // } // for (int m = l - 1; m >= 0; m--) { // System.out.print(ans[m]); // } // System.out.println(); // } // // } // // sc.close(); // } public static void main(String[] args) { new Main().run(); } }
a.cc:3:1: error: 'import' does not name a type 3 | import java.util.Scanner; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:5:1: error: expected unqualified-id before 'public' 5 | public class Main { | ^~~~~~
s766913020
p00015
C++
#include<iostream> #include<cstring> #include<cstdlib> using namespace std; int main() { int N,j; cin >> N; for(int i=0 ; i<N ; i++){ int ans[81]={0}; ans[0]=11111; char strA[100],strB[100]; cin >> strA >> strB; if(strlen(strA)>80||strlen(strB)>80){ cout << "overflow" << endl; continue; } char str1[strlen(strA)][2],str2[strlen(strB)][2]; for(int i=0 ; i<strlen(strA) ; i++){ str1[i][0]=strA[i]; str1[i][1]='\0'; } for(int i=0 ; i<strlen(strB) ; i++){ str2[i][0]=strB[i]; str2[i][1]='\0'; } int a[81]={0},b[81]={0}; j=strlen(strA)-1; for(int i=80 ; j>=0 ; i--){ a[i]=atoi(str1[j]); j--; } j=strlen(strB)-1; for(int i=80 ; j>=0 ; i--){ b[i]=atoi(str2[j]); j--; } for(int i=80 ; i!=0 ; i--){ ans[i]=ans[i]+a[i]+b[i]; if(ans[i]>=10){ ans[i]=ans[i]-10; ans[i-1]++; } } if(ans[0]!=11111){ cout << "overflow" << endl; continue; } for(int i=1 ; i<81 ; i++){ if(ans[i]!=0){ j=i; break; } } char c[2]; for(int i=j ; i<81 ; i++){ itoa(ans[i],c,10); cout << c; } cout << '\n'; } return 0; }
a.cc: In function 'int main()': a.cc:58:13: error: 'itoa' was not declared in this scope 58 | itoa(ans[i],c,10); | ^~~~
s677854651
p00015
C++
#include<iostream> #include<cstring> #include<stdlib.h> using namespace std; int main() { int N,j; cin >> N; for(int i=0 ; i<N ; i++){ int ans[81]={0}; ans[0]=11111; char strA[100],strB[100]; cin >> strA >> strB; if(strlen(strA)>80||strlen(strB)>80){ cout << "overflow" << endl; continue; } char str1[strlen(strA)][2],str2[strlen(strB)][2]; for(int i=0 ; i<strlen(strA) ; i++){ str1[i][0]=strA[i]; str1[i][1]='\0'; } for(int i=0 ; i<strlen(strB) ; i++){ str2[i][0]=strB[i]; str2[i][1]='\0'; } int a[81]={0},b[81]={0}; j=strlen(strA)-1; for(int i=80 ; j>=0 ; i--){ a[i]=atoi(str1[j]); j--; } j=strlen(strB)-1; for(int i=80 ; j>=0 ; i--){ b[i]=atoi(str2[j]); j--; } for(int i=80 ; i!=0 ; i--){ ans[i]=ans[i]+a[i]+b[i]; if(ans[i]>=10){ ans[i]=ans[i]-10; ans[i-1]++; } } if(ans[0]!=11111){ cout << "overflow" << endl; continue; } for(int i=1 ; i<81 ; i++){ if(ans[i]!=0){ j=i; break; } } char c[2]; for(int i=j ; i<81 ; i++){ itoa(ans[i],c,10); cout << c; } cout << '\n'; } return 0; }
a.cc: In function 'int main()': a.cc:58:13: error: 'itoa' was not declared in this scope 58 | itoa(ans[i],c,10); | ^~~~
s297410375
p00015
C++
#include <iostream> #include <string> ?? using namespace std; ?? int main() { ????????int num; ?? ????????cin >> num; ????????for (int i = 0; i < num; i++) { ????????????????string s1, s2; ?? ????????????????cin >> s1 >> s2; ????????????????if (s1.size() > 80 || s2.size() > 80) ????????????????????????cout << "overflow" << endl; ????????????????else { ????????????????????????int i1 = s1.size(); ????????????????????????int i2 = s2.size(); ????????????????????????string ans; ????????????????????????int tmp = 0; ????????????????????????int up = 0; ?? ????????????????????????for ( ; (i1 > 0) && (i2 > 0); i1--, i2-- ) { ????????????????????????????????tmp = (s1[i1 - 1] + s2[i2 - 1]) - 2 * '0' + up; ????????????????????????????????up = tmp / 10; ????????????????????????????????tmp %= 10; ????????????????????????????????ans = char(tmp + '0') + ans; ????????????????????????} ?????????????????????????? ????????????????????????if (i1 > 0) { ????????????????????????????????for ( ; i1 > 0; i1--) { ????????????????????????????????????????tmp = s1[i1 - 1] - '0' + up; ????????????????????????????????????????up = tmp / 10; ????????????????????????????????????????tmp %= 10; ????????????????????????????????????????ans = char(tmp + '0') + ans; ????????????????????????????????} ????????????????????????} ????????????????????????else if (i2 > 0) { ????????????????????????????????for ( ; i2 > 0; i2--) { ????????????????????????????????????????tmp = s2[i2 - 1] - '0' + up; ????????????????????????????????????????up = tmp / 10; ????????????????????????????????????????tmp %= 10; ????????????????????????????????????????ans = char(tmp + '0') + ans; ????????????????????????????????} ????????????????????????} ?? ????????????????????????if (up > 0) ????????????????????????????????ans = char(up + '0') + ans; ?? ????????????????????????if (ans.size() > 80) ????????????????????????????????cout << "overflow" << endl; ????????????????????????else ????????????????????????????????cout << ans << endl; ????????????????} ????????} ?? ????????return 0; }
a.cc:3:1: error: expected unqualified-id before '?' token 3 | ?? | ^ a.cc:5:1: error: expected unqualified-id before '?' token 5 | ?? | ^
s133164901
p00015
C++
/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; import java.math.*; /* Name of the class has to be "Main" only if the class is public. */ public class Main { public static void main (String[] args) throws java.lang.Exception { Scanner sc = new Scanner(System.in); int q = sc.nextInt(); for(int i = 0; i < q; ++i){ BigInteger n1 = sc.nextBigInteger(); BigInteger n2 = sc.nextBigInteger(); BigInteger ans = n1.add(n2); String sa = ans.toString(); if(sa.length() > 80){ System.out.println("overflow"); } else{ System.out.println(sa); } } } }
a.cc:3:1: error: 'import' does not name a type 3 | import java.util.*; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: 'import' does not name a type 4 | import java.lang.*; | ^~~~~~ a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:5:1: error: 'import' does not name a type 5 | import java.io.*; | ^~~~~~ a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:6:1: error: 'import' does not name a type 6 | import java.math.*; | ^~~~~~ a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:9:1: error: expected unqualified-id before 'public' 9 | public class Main | ^~~~~~
s008327865
p00015
C++
#include<iostream> #include<string> #include<cstring> using namespace std; int main(){ string s1,s2; int num; cin>>num; for(int j=0;j<num;j++){ cin>>s1; cin>>s2; int size1=s1.size(); int size2=s2.size(); if(size1>80 || size2>80){ cout<<"overflow"<<endl; continue; } if(size1>size2){ for(int a=0;a<(size1-size2);a++){ s2='0'+s2; } }else if(size1<size2){ for(int a=0;a<(size2-size1);a++){ s1='0'+s1; } } string ans=""; int plus=0; for(int i=size1-1;i>=-1;i--){ if(i==-1){ if(plus!=0){ ans=(char)(plus+'0')+ans; continue; }else{ continue; } } int alt=(s1[i]-'0')+(s2[i]-'0')+plus; if(alt>=10){ ans=(char)(alt-10+'0')+ans; plus=alt/10; }else ans=(char)(alt+'0')+ans; } if(ans.size()>80){ cout<<overflow<<endl; }else{ cout<<ans<<endl; } } return 0; }
a.cc: In function 'int main()': a.cc:46:31: error: 'overflow' was not declared in this scope 46 | cout<<overflow<<endl; | ^~~~~~~~
s264206264
p00015
C++
n = int(raw_input()) while n: n -= 1 a = long(raw_input()) b = long(raw_input()) c = str(a + b) if len(c) > 80: print "overflow" else: print c
a.cc:1:1: error: 'n' does not name a type 1 | n = int(raw_input()) | ^
s105298104
p00015
C++
#include <iostream> #include <cstdio> #include <cstdlib> using namespace std; int main(){ int n; cin >> n; for(int j=0;j<n;j++){ char a[81],b[81],c[81]; int ka = 0; int kb = 0; int kc = 0; bool ovf = false; cin >> a[ka]; ka++; while(1){ scanf("%c",&a[ka]); if(ka==80 and a[ka]!='\n') ovf = true; if(a[ka]=='\n' or ovf) break; ka++; } while(1){ scanf("%c",&b[kb]); if(kb==80 and b[kb]!='\n') ovf = true; if(b[kb]=='\n' or ovf) break; kb++; } int k = 0; char t; for(int i=0;i<81;i++){ if(i==80 and k==1) ovf = true; if((ka<=i and kb<=i) or ovf) break; int ia = 0; t = a[ka-i-1]; if(ka>=i) ia = atoi(&t); int ib = 0; t = b[kb-i-1]; if(kb>=i) ib = atoi(&t); int s = ia + ib + k; k = 0; if(s>9){ k = 1; s = s%10;} itoa(s,&c[i],10); kc++; } if(ovf) cout << "overflow" << endl; else{ for(int i=kc-1;i>=0;i--) cout << c[i]; cout << endl; } } }
a.cc: In function 'int main()': a.cc:43:25: error: 'itoa' was not declared in this scope; did you mean 'ia'? 43 | itoa(s,&c[i],10); | ^~~~ | ia
s851619259
p00015
C++
#include <iostream> #include <cstdio> #include <cstdlib> using namespace std; int main(){ int n; cin >> n; for(int j=0;j<n;j++){ char a[81],b[81],c[81]; int ka = 0; int kb = 0; int kc = 0; bool ovf = false; cin >> a[ka]; ka++; while(1){ scanf("%c",&a[ka]); if(ka==80 and a[ka]!='\n') ovf = true; if(a[ka]=='\n' or ovf) break; ka++; } while(1){ scanf("%c",&b[kb]); if(kb==80 and b[kb]!='\n') ovf = true; if(b[kb]=='\n' or ovf) break; kb++; } int k = 0; char t; for(int i=0;i<81;i++){ if(i==80 and k==1) ovf = true; if((ka<=i and kb<=i) or ovf) break; int ia = 0; t = a[ka-i-1]; if(ka>=i) ia = atoi(&t); int ib = 0; t = b[kb-i-1]; if(kb>=i) ib = atoi(&t); int s = ia + ib + k; k = 0; if(s>9){ k = 1; s = s%10;} itoa(s,&c[i],10); kc++; } if(ovf) cout << "overflow" << endl; else{ for(int i=kc-1;i>=0;i--) cout << c[i]; cout << endl; } } }
a.cc: In function 'int main()': a.cc:43:25: error: 'itoa' was not declared in this scope; did you mean 'ia'? 43 | itoa(s,&c[i],10); | ^~~~ | ia
s131967697
p00015
C++
#include <cmath> #include <iostream> #include <string> #include <cstdlib> using namespace std; int main(){ string inp[2]; int output[81],n; cin >> n; while(n--){ cin >> inp[0] >> inp[1]; if(inp[0].size()>80||inp[0].size()>80) cout << "overflow" << endl; else{ fill(output,output+81,0); reverse(inp[0].begin(),inp[0].end()); reverse(inp[1].begin(),inp[1].end()); for(int i=0;i<81;i++){ if(i<inp[0].size()) output[i]+=inp[0][i]-'0'; if(i<inp[1].size()) output[i]+=inp[1][i]-'0'; if(i!=80&&output[i]>9){ output[i+1]+=output[i]/10; output[i]%=10; } } if(output[80]>0) cout << "overflow" << endl; else{ bool flag=false; for(int i=79;i>=0;i--){ if((!flag&&output[i]!=0)||i==0) flag=true; if(flag) cout << output[i]; } cout << endl; } } } return 0; }
a.cc: In function 'int main()': a.cc:17:13: error: 'reverse' was not declared in this scope 17 | reverse(inp[0].begin(),inp[0].end()); | ^~~~~~~
s573239404
p00015
C++
#include <iostream> #include <algorithm> namespace boost {template <class T>struct integer_iterator {T a;bool operator != (integer_iterator const & it) const { return a != it.a; }T operator * () const { return a; }integer_iterator & operator ++ () { ++ a; return *this; }integer_iterator operator ++ (int) { return { a ++ }; }};template <class T>struct integer_range {T l, r;typedef integer_iterator<T> iterator;iterator begin() const { return { l }; }iterator end () const { return { r }; }};template <class T>integer_range<T> irange(T l, T r) { return { l, r }; }template <class T>struct integer_iterator_with_step {T a, d, i;bool operator != (integer_iterator_with_step const & it) const { return a != it.a or d != it.d or i != it.i; }T operator * () const { return a+d*i; }integer_iterator_with_step & operator ++ () { ++ i; return *this; }integer_iterator_with_step operator ++ (int) { return { a, d, i ++ }; }};template <class T>struct strided_integer_range {T l, r, s;typedef integer_iterator_with_step<T> iterator;iterator begin() const { return { l, s, 0 }; }iterator end () const { return { l, s, (r - l) / s }; }};template <class T>strided_integer_range<T> irange(T l, T r, T s) { return { l, r, s }; }} #include <vector> #include <sstream> #include <cassert> #include <complex> #include <cmath> // O (n log n) template <typename T>void fft_inplace(std::vector<std::complex<T> > & f, int dir) {using namespace std;using namespace boost;int n = f.size();assert (n == pow(2,log2(n)));if (n == 1) return;vector<complex<T> > a(n/2), b(n/2);for (int i : irange(0,n/2)) {a[i] = f[2*i];b[i] = f[2*i+1];}fft_inplace(a, dir);fft_inplace(b, dir);const complex<T> zeta = polar<T>(1, dir*2*M_PI/n);complex<T> pow_zeta = 1;for (int i : irange(0,n)) {f[i] = a[i % (n/2)] + pow_zeta * b[i % (n/2)];pow_zeta *= zeta;}}template <typename T>std::vector<std::complex<T> > fft(std::vector<std::complex<T> > f) {using namespace std;f.resize(pow(2,ceil(log2(f.size()))));fft_inplace(f, +1);return f;}template <typename T>std::vector<std::complex<T> > ifft(std::vector<std::complex<T> > f) {using namespace std;f.resize(pow(2,ceil(log2(f.size()))));fft_inplace(f, -1);return f;}template <typename T, typename R = double>std::vector<T> convolution(std::vector<T> const & a, std::vector<T> const & b) {using namespace std;using namespace boost;int m = a.size() + b.size() - 1;int n = pow(2,ceil(log2(m)));vector<complex<R> > x(n), y(n);copy(a.begin(), a.end(), x.begin());copy(b.begin(), b.end(), y.begin());x = fft(x);y = fft(y);vector<complex<R> > z(n);for (int i : irange(0,n)) z[i] = x[i] * y[i];z = ifft(z);vector<T> c(m);for (int i : irange(0,m)) c[i] = round(z[i].real() / n);return c;} namespace boost {namespace multiprecision {struct cpp_int {typedef long long ll;bool sign;std::vector<ll> ds;static constexpr int p = 10;void normalize() {for (int i = 0; i < ds.size() /* may be changed in loop */; ++i) {if (not (0 <= ds[i] and ds[i] < p)) {if (not (i+1 < ds.size())) ds.push_back(0);ds[i+1] += ds[i] / p;ds[i] %= p;if (ds[i] < 0) {ds[i] += p;ds[i+1] -= 1;}}}while (not ds.empty() and ds.back() == 0) ds.pop_back();}cpp_int() : sign(false), ds(0) {}cpp_int(std::vector<ll> ds_) : sign(false), ds(ds_) {normalize();}cpp_int(std::string const & s) {sign = (s.front() == '-');int t = sign ? 1 : 0;for (int i : boost::irange<int>(t,s.size())) assert ('0' <= s[i] and s[i] <= '9');ds.resize(s.size() - t);for (int i : boost::irange<int>(t,s.size())) ds[ds.size()-(i-t)-1] = s[i] - '0';}std::string str() const {std::stringstream s;if (sign) s << '-';for (int i : boost::irange<int>(ds.size()-1,-1,-1)) s << (char)(ds[i] + '0');return s.str();}};inline bool operator == (cpp_int const & a, cpp_int const & b) {return a.sign == b.sign and a.ds == b.ds;}inline bool operator != (cpp_int const & a, cpp_int const & b) {return not (a == b);}inline bool operator < (cpp_int const & a, cpp_int const & b) {if (a.sign and not b.sign) {return true;} else if (not a.sign and b.sign) {return false;} else if (a.sign and b.sign) {if (a.ds.size() != b.ds.size()) {return a.ds.size() > b.ds.size();} else {return a.ds > b.ds;}} else {if (a.ds.size() != b.ds.size()) {return a.ds.size() < b.ds.size();} else {return a.ds < b.ds;}}}inline bool operator >= (cpp_int const & a, cpp_int const & b) {return not (a < b);}inline bool operator > (cpp_int const & a, cpp_int const & b) {return a >= b and a != b;}inline bool operator <= (cpp_int const & a, cpp_int const & b) {return a < b or a == b;}inline cpp_int & operator ++ (cpp_int & a) {a.ds.front() += 1;a.normalize();return a;}inline cpp_int & operator -- (cpp_int & a) {a.ds.front() -= 1;a.normalize();return a;}inline cpp_int operator - (cpp_int a) {a.sign = not a.sign;return a;}inline cpp_int operator - (cpp_int const & a, cpp_int const & b);inline cpp_int operator + (cpp_int const & a, cpp_int const & b) {if (a.sign and not b.sign) {return b - (- a);} else if (not a.sign and b.sign) {return a - (- b);} else if (a.sign and b.sign) {return - ((- a) + (- b));} else {assert (not a.sign and not b.sign);int an = a.ds.size();int bn = b.ds.size();cpp_int c;c.ds.resize(std::max(an,bn));for (int i : boost::irange(0,an)) c.ds[i] += a.ds[i];for (int i : boost::irange(0,bn)) c.ds[i] += b.ds[i];c.normalize();return c;}}inline cpp_int operator - (cpp_int const & a, cpp_int const & b) {if (a.sign and not b.sign) {return - ((- a) + b);} else if (not a.sign and b.sign) {return a + (- b);} else if (a.sign and b.sign) {return - ((- a) - (- b));} else if (b > a) {return - (b - a);} else {assert (not a.sign and not b.sign and a >= b);int an = a.ds.size();int bn = b.ds.size();cpp_int c;c.ds.resize(std::max(an,bn));for (int i : boost::irange(0,an)) c.ds[i] += a.ds[i];for (int i : boost::irange(0,bn)) c.ds[i] -= b.ds[i];c.normalize();return c;}}inline cpp_int & operator += (cpp_int & a, cpp_int const & b) {return a = a + b;return a;}inline cpp_int & operator -= (cpp_int & a, cpp_int const & b) {return a = a - b;return a;}inline cpp_int & operator *= (cpp_int & a, cpp_int const & b) {a.ds = convolution(a.ds, b.ds);a.normalize();a.sign = a.sign != b.sign;return a;}inline cpp_int operator * (cpp_int a, cpp_int const & b) {return a *= b;}inline std::istream & operator >> (std::istream & input, cpp_int & a) {std::string s; input >> s;a = cpp_int(s);return input;}inline std::ostream & operator << (std::ostream & output, cpp_int const & a) {return output << a.str();}}} using namespace std; using namespace boost; #define MAX_DIGIT 80 int main() { int n; cin >> n; for (int testcase : irange(0,n)) { string a, b; cin >> a >> b; if (a.size() > 80 or b.size() > 80) { cout << "overflow" << endl; continue; } string c = cpp_int(cpp_int(a) + cpp_int(b)).str(); if (c.size() > 80) { cout << "overflow" << endl; continue; } cout << c << endl; } return 0; }
a.cc: In function 'int main()': a.cc:23:28: error: 'cpp_int' was not declared in this scope; did you mean 'boost::multiprecision::cpp_int'? 23 | string c = cpp_int(cpp_int(a) + cpp_int(b)).str(); | ^~~~~~~ | boost::multiprecision::cpp_int a.cc:11:51: note: 'boost::multiprecision::cpp_int' declared here 11 | namespace boost {namespace multiprecision {struct cpp_int {typedef long long ll;bool sign;std::vector<ll> ds;static constexpr int p = 10;void normalize() {for (int i = 0; i < ds.size() /* may be changed in loop */; ++i) {if (not (0 <= ds[i] and ds[i] < p)) {if (not (i+1 < ds.size())) ds.push_back(0);ds[i+1] += ds[i] / p;ds[i] %= p;if (ds[i] < 0) {ds[i] += p;ds[i+1] -= 1;}}}while (not ds.empty() and ds.back() == 0) ds.pop_back();}cpp_int() : sign(false), ds(0) {}cpp_int(std::vector<ll> ds_) : sign(false), ds(ds_) {normalize();}cpp_int(std::string const & s) {sign = (s.front() == '-');int t = sign ? 1 : 0;for (int i : boost::irange<int>(t,s.size())) assert ('0' <= s[i] and s[i] <= '9');ds.resize(s.size() - t);for (int i : boost::irange<int>(t,s.size())) ds[ds.size()-(i-t)-1] = s[i] - '0';}std::string str() const {std::stringstream s;if (sign) s << '-';for (int i : boost::irange<int>(ds.size()-1,-1,-1)) s << (char)(ds[i] + '0');return s.str();}};inline bool operator == (cpp_int const & a, cpp_int const & b) {return a.sign == b.sign and a.ds == b.ds;}inline bool operator != (cpp_int const & a, cpp_int const & b) {return not (a == b);}inline bool operator < (cpp_int const & a, cpp_int const & b) {if (a.sign and not b.sign) {return true;} else if (not a.sign and b.sign) {return false;} else if (a.sign and b.sign) {if (a.ds.size() != b.ds.size()) {return a.ds.size() > b.ds.size();} else {return a.ds > b.ds;}} else {if (a.ds.size() != b.ds.size()) {return a.ds.size() < b.ds.size();} else {return a.ds < b.ds;}}}inline bool operator >= (cpp_int const & a, cpp_int const & b) {return not (a < b);}inline bool operator > (cpp_int const & a, cpp_int const & b) {return a >= b and a != b;}inline bool operator <= (cpp_int const & a, cpp_int const & b) {return a < b or a == b;}inline cpp_int & operator ++ (cpp_int & a) {a.ds.front() += 1;a.normalize();return a;}inline cpp_int & operator -- (cpp_int & a) {a.ds.front() -= 1;a.normalize();return a;}inline cpp_int operator - (cpp_int a) {a.sign = not a.sign;return a;}inline cpp_int operator - (cpp_int const & a, cpp_int const & b);inline cpp_int operator + (cpp_int const & a, cpp_int const & b) {if (a.sign and not b.sign) {return b - (- a);} else if (not a.sign and b.sign) {return a - (- b);} else if (a.sign and b.sign) {return - ((- a) + (- b));} else {assert (not a.sign and not b.sign);int an = a.ds.size();int bn = b.ds.size();cpp_int c;c.ds.resize(std::max(an,bn));for (int i : boost::irange(0,an)) c.ds[i] += a.ds[i];for (int i : boost::irange(0,bn)) c.ds[i] += b.ds[i];c.normalize();return c;}}inline cpp_int operator - (cpp_int const & a, cpp_int const & b) {if (a.sign and not b.sign) {return - ((- a) + b);} else if (not a.sign and b.sign) {return a + (- b);} else if (a.sign and b.sign) {return - ((- a) - (- b));} else if (b > a) {return - (b - a);} else {assert (not a.sign and not b.sign and a >= b);int an = a.ds.size();int bn = b.ds.size();cpp_int c;c.ds.resize(std::max(an,bn));for (int i : boost::irange(0,an)) c.ds[i] += a.ds[i];for (int i : boost::irange(0,bn)) c.ds[i] -= b.ds[i];c.normalize();return c;}}inline cpp_int & operator += (cpp_int & a, cpp_int const & b) {return a = a + b;return a;}inline cpp_int & operator -= (cpp_int & a, cpp_int const & b) {return a = a - b;return a;}inline cpp_int & operator *= (cpp_int & a, cpp_int const & b) {a.ds = convolution(a.ds, b.ds);a.normalize();a.sign = a.sign != b.sign;return a;}inline cpp_int operator * (cpp_int a, cpp_int const & b) {return a *= b;}inline std::istream & operator >> (std::istream & input, cpp_int & a) {std::string s; input >> s;a = cpp_int(s);return input;}inline std::ostream & operator << (std::ostream & output, cpp_int const & a) {return output << a.str();}}} | ^~~~~~~ a.cc:23:20: error: 'cpp_int' was not declared in this scope; did you mean 'boost::multiprecision::cpp_int'? 23 | string c = cpp_int(cpp_int(a) + cpp_int(b)).str(); | ^~~~~~~ | boost::multiprecision::cpp_int a.cc:11:51: note: 'boost::multiprecision::cpp_int' declared here 11 | namespace boost {namespace multiprecision {struct cpp_int {typedef long long ll;bool sign;std::vector<ll> ds;static constexpr int p = 10;void normalize() {for (int i = 0; i < ds.size() /* may be changed in loop */; ++i) {if (not (0 <= ds[i] and ds[i] < p)) {if (not (i+1 < ds.size())) ds.push_back(0);ds[i+1] += ds[i] / p;ds[i] %= p;if (ds[i] < 0) {ds[i] += p;ds[i+1] -= 1;}}}while (not ds.empty() and ds.back() == 0) ds.pop_back();}cpp_int() : sign(false), ds(0) {}cpp_int(std::vector<ll> ds_) : sign(false), ds(ds_) {normalize();}cpp_int(std::string const & s) {sign = (s.front() == '-');int t = sign ? 1 : 0;for (int i : boost::irange<int>(t,s.size())) assert ('0' <= s[i] and s[i] <= '9');ds.resize(s.size() - t);for (int i : boost::irange<int>(t,s.size())) ds[ds.size()-(i-t)-1] = s[i] - '0';}std::string str() const {std::stringstream s;if (sign) s << '-';for (int i : boost::irange<int>(ds.size()-1,-1,-1)) s << (char)(ds[i] + '0');return s.str();}};inline bool operator == (cpp_int const & a, cpp_int const & b) {return a.sign == b.sign and a.ds == b.ds;}inline bool operator != (cpp_int const & a, cpp_int const & b) {return not (a == b);}inline bool operator < (cpp_int const & a, cpp_int const & b) {if (a.sign and not b.sign) {return true;} else if (not a.sign and b.sign) {return false;} else if (a.sign and b.sign) {if (a.ds.size() != b.ds.size()) {return a.ds.size() > b.ds.size();} else {return a.ds > b.ds;}} else {if (a.ds.size() != b.ds.size()) {return a.ds.size() < b.ds.size();} else {return a.ds < b.ds;}}}inline bool operator >= (cpp_int const & a, cpp_int const & b) {return not (a < b);}inline bool operator > (cpp_int const & a, cpp_int const & b) {return a >= b and a != b;}inline bool operator <= (cpp_int const & a, cpp_int const & b) {return a < b or a == b;}inline cpp_int & operator ++ (cpp_int & a) {a.ds.front() += 1;a.normalize();return a;}inline cpp_int & operator -- (cpp_int & a) {a.ds.front() -= 1;a.normalize();return a;}inline cpp_int operator - (cpp_int a) {a.sign = not a.sign;return a;}inline cpp_int operator - (cpp_int const & a, cpp_int const & b);inline cpp_int operator + (cpp_int const & a, cpp_int const & b) {if (a.sign and not b.sign) {return b - (- a);} else if (not a.sign and b.sign) {return a - (- b);} else if (a.sign and b.sign) {return - ((- a) + (- b));} else {assert (not a.sign and not b.sign);int an = a.ds.size();int bn = b.ds.size();cpp_int c;c.ds.resize(std::max(an,bn));for (int i : boost::irange(0,an)) c.ds[i] += a.ds[i];for (int i : boost::irange(0,bn)) c.ds[i] += b.ds[i];c.normalize();return c;}}inline cpp_int operator - (cpp_int const & a, cpp_int const & b) {if (a.sign and not b.sign) {return - ((- a) + b);} else if (not a.sign and b.sign) {return a + (- b);} else if (a.sign and b.sign) {return - ((- a) - (- b));} else if (b > a) {return - (b - a);} else {assert (not a.sign and not b.sign and a >= b);int an = a.ds.size();int bn = b.ds.size();cpp_int c;c.ds.resize(std::max(an,bn));for (int i : boost::irange(0,an)) c.ds[i] += a.ds[i];for (int i : boost::irange(0,bn)) c.ds[i] -= b.ds[i];c.normalize();return c;}}inline cpp_int & operator += (cpp_int & a, cpp_int const & b) {return a = a + b;return a;}inline cpp_int & operator -= (cpp_int & a, cpp_int const & b) {return a = a - b;return a;}inline cpp_int & operator *= (cpp_int & a, cpp_int const & b) {a.ds = convolution(a.ds, b.ds);a.normalize();a.sign = a.sign != b.sign;return a;}inline cpp_int operator * (cpp_int a, cpp_int const & b) {return a *= b;}inline std::istream & operator >> (std::istream & input, cpp_int & a) {std::string s; input >> s;a = cpp_int(s);return input;}inline std::ostream & operator << (std::ostream & output, cpp_int const & a) {return output << a.str();}}} | ^~~~~~~
s675308543
p00015
C++
n = gets.to_i n.times do x = gets.to_i + gets.to_i puts x < 10**80 ? x : "overflow" end
a.cc:1:1: error: 'n' does not name a type 1 | n = gets.to_i | ^
s170407266
p00015
C++
#include<cstdio> #include<algorithm> #include<vector> #include<string> #include<iostream> #include<queue> #include<map> #include<set> #include<complex> #include<stack> using namespace std; int main(){ int n; cin>>n; while(n-- > 0){ vector<int> ans; vector<int> a; vector<int> b; string c,d; cin>>c>>d; for(int i = 0; i < (int)c.size(); ++i){ a.push_back(c[c.size()-1-i]-'0'); } for(int i = 0; i < (int)d.size(); ++i){ b.push_back(d[d.size()-1-i]-'0'); } int kuri = 0; while(!a.empty() || !b.empty() || kuri!=0){ int sum = kuri; kuri = 0; if(!a.empty()){ sum += a[0]; a.erase(a.begin()); } if(!b.empty()){ sum += b[0]; b.erase(b.begin()); } ans.push_back(sum%10); kuri += sum/10; } if(ans.size()>80)puts("overflow"); else{ for(int i = 0; i < (int)ans.size(); ++i){ printf("%d",ans[ans.size()-1-i]); }puts(""); } } } /* #include <iostream> #include <string> #include <algorithm> using namespace std; int main(){ cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; while(n-- > 0){ string str1; cin >> str1; string str2; cin >> str2; reverse(str1.begin(), str1.end()); reverse(str2.begin(), str2.end()); int check; if(str1.size() > str2.size()){ check = 1; } else if(str1.size() == str2.size()){ check = 2; } else { check = 3; } int ans[100]; bool next = false; int short_ = min(str1.size(), str2.size()); int long_ = max(str1.size(), str2.size()); if(long_ >= 80){ cout << "overflow" << endl; continue; } for(int i = 0; i < short_; ++i){ int num = 0; num += (str1[i] - '0') + (str2[i] - '0'); if(next){ num++; } ans[i] = num; next = false; if(num >= 10){ num -= 10; ans[i] -= 10; next = true; } } if(check == 1){ for(size_t i = str2.size(); i < str1.size(); ++i){ int num = str1[i] - '0'; if(next){ num++; } ans[i] = num; next = false; if(num >= 10){ num -= 10; ans[i] -= 10; next = true; } } if(next){ ans[str1.size()] = 1; long_ ++; } } if(check == 3){ for(size_t i = str1.size(); i < str2.size(); ++i){ int num = str2[i] - '0'; if(next){ num++; } ans[i] = num; next = false; if(num >= 10){ num -= 10; ans[i] -= 10; next = true; } } if(next){ ans[str2.size()] = 1; long_ ++; } } if(long_ >= 80){ cout << "overflow" << endl; continue; } for(int i = long_ - 1; i >= 0; --i){ cout << ans[i]; } cout << endl; } return 0; } *
a.cc:64:1: error: unterminated comment 64 | /* | ^
s232402230
p00015
C++
#include<cstdio> #include<algorithm> #include<vector> #include<string> #include<iostream> #include<queue> #include<map> #include<set> #include<complex> #include<stack> using namespace std; int main(){ int n; cin>>n; while(n-- > 0){ vector<int> ans; vector<int> a; vector<int> b; string c,d; cin>>c>>d; for(int i = 0; i < (int)c.size(); ++i){ a.push_back(c[c.size()-1-i]-'0'); } for(int i = 0; i < (int)d.size(); ++i){ b.push_back(d[d.size()-1-i]-'0'); } int kuri = 0; while(!a.empty() || !b.empty() || kuri!=0){ int sum = kuri; kuri = 0; if(!a.empty()){ sum += a[0]; a.erase(a.begin()); } if(!b.empty()){ sum += b[0]; b.erase(b.begin()); } ans.push_back(sum%10); kuri += sum/10; } if(ans.size()>80)puts("overflow"); else{ for(int i = 0; i < (int)ans.size(); ++i){ printf("%d",ans[ans.size()-1-i]); }puts(""); } } } /* #include <iostream> #include <string> #include <algorithm> using namespace std; int main(){ cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; while(n-- > 0){ string str1; cin >> str1; string str2; cin >> str2; reverse(str1.begin(), str1.end()); reverse(str2.begin(), str2.end()); int check; if(str1.size() > str2.size()){ check = 1; } else if(str1.size() == str2.size()){ check = 2; } else { check = 3; } int ans[100]; bool next = false; int short_ = min(str1.size(), str2.size()); int long_ = max(str1.size(), str2.size()); if(long_ >= 80){ cout << "overflow" << endl; continue; } for(int i = 0; i < short_; ++i){ int num = 0; num += (str1[i] - '0') + (str2[i] - '0'); if(next){ num++; } ans[i] = num; next = false; if(num >= 10){ num -= 10; ans[i] -= 10; next = true; } } if(check == 1){ for(size_t i = str2.size(); i < str1.size(); ++i){ int num = str1[i] - '0'; if(next){ num++; } ans[i] = num; next = false; if(num >= 10){ num -= 10; ans[i] -= 10; next = true; } } if(next){ ans[str1.size()] = 1; long_ ++; } } if(check == 3){ for(size_t i = str1.size(); i < str2.size(); ++i){ int num = str2[i] - '0'; if(next){ num++; } ans[i] = num; next = false; if(num >= 10){ num -= 10; ans[i] -= 10; next = true; } } if(next){ ans[str2.size()] = 1; long_ ++; } } if(long_ >= 80){ cout << "overflow" << endl; continue; } for(int i = long_ - 1; i >= 0; --i){ cout << ans[i]; } cout << endl; } return 0; } *
a.cc:64:1: error: unterminated comment 64 | /* | ^
s278454556
p00015
C++
#include<cstdio> #include<algorithm> #include<vector> #include<string> #include<iostream> #include<queue> #include<map> #include<set> #include<complex> #include<stack> using namespace std; int main(){ int n; cin>>n; while(n-- > 0){ vector<int> ans; vector<int> a; vector<int> b; string c,d; cin>>c>>d; for(int i = 0; i < (int)c.size(); ++i){ a.push_back(c[c.size()-1-i]-'0'); } for(int i = 0; i < (int)d.size(); ++i){ b.push_back(d[d.size()-1-i]-'0'); } int kuri = 0; while(!a.empty() || !b.empty() || kuri!=0){ int sum = kuri; kuri = 0; if(!a.empty()){ sum += a[0]; a.erase(a.begin()); } if(!b.empty()){ sum += b[0]; b.erase(b.begin()); } ans.push_back(sum%10); kuri += sum/10; } if(ans.size()>80)puts("overflow"); else{ for(int i = 0; i < (int)ans.size(); ++i){ printf("%d",ans[ans.size()-1-i]); }puts(""); } } } /* #include <iostream> #include <string> #include <algorithm> using namespace std; int main(){ cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; while(n-- > 0){ string str1; cin >> str1; string str2; cin >> str2; reverse(str1.begin(), str1.end()); reverse(str2.begin(), str2.end()); int check; if(str1.size() > str2.size()){ check = 1; } else if(str1.size() == str2.size()){ check = 2; } else { check = 3; } int ans[100]; bool next = false; int short_ = min(str1.size(), str2.size()); int long_ = max(str1.size(), str2.size()); if(long_ >= 80){ cout << "overflow" << endl; continue; } for(int i = 0; i < short_; ++i){ int num = 0; num += (str1[i] - '0') + (str2[i] - '0'); if(next){ num++; } ans[i] = num; next = false; if(num >= 10){ num -= 10; ans[i] -= 10; next = true; } } if(check == 1){ for(size_t i = str2.size(); i < str1.size(); ++i){ int num = str1[i] - '0'; if(next){ num++; } ans[i] = num; next = false; if(num >= 10){ num -= 10; ans[i] -= 10; next = true; } } if(next){ ans[str1.size()] = 1; long_ ++; } } if(check == 3){ for(size_t i = str1.size(); i < str2.size(); ++i){ int num = str2[i] - '0'; if(next){ num++; } ans[i] = num; next = false; if(num >= 10){ num -= 10; ans[i] -= 10; next = true; } } if(next){ ans[str2.size()] = 1; long_ ++; } } if(long_ >= 80){ cout << "overflow" << endl; continue; } for(int i = long_ - 1; i >= 0; --i){ cout << ans[i]; } cout << endl; } return 0; }
a.cc:64:1: error: unterminated comment 64 | /* | ^
s343166658
p00015
C++
#include<stdio.h> #include<iostream> #include<list> #include<map> #include<vector> #include<algorithm> #include<string.h> #define range(i,a,b) for(int i = (a); i < (b); i++) #define rep(i,b) range(i,0,b) #define debug(x) cout << x << endl; using namespace std; int main(){ int n,g; int k,l; bool check; cin >> n; rep(i,n){ char c1[81], c2[81]; int i1[81] = {0}, i2[81] = {0}; int ans[82] = {0}; check = false; k = 0; l = 0; cin >> c1 >> c2; /* for(int j = 80; 0 <= j; j--){ if(j <= strlen(c1) - 1){ i1[k] = c1[j] - '0'; k++; } if(j <= strlen(c2) - 1){ i2[l] = c2[j] - '0'; l++; }*/ } rep(j, 80){ ans[j]+= i1[j] + i2[j]; if(ans[j] >= 10){ ans[j]-=10; ans[j+1]++; } } if(ans[80] != 0){ cout << "overflow"; }else{ for(int j = 81; 0 <= j; j--){ if(ans[j] != 0){ check = true; } if(check == true) cout << ans[j]; } } cout << endl; } }
a.cc: In function 'int main()': a.cc:37:13: error: 'ans' was not declared in this scope; did you mean 'abs'? 37 | ans[j]+= i1[j] + i2[j]; | ^~~ | abs a.cc:37:22: error: 'i1' was not declared in this scope 37 | ans[j]+= i1[j] + i2[j]; | ^~ a.cc:37:30: error: 'i2' was not declared in this scope 37 | ans[j]+= i1[j] + i2[j]; | ^~ a.cc:43:12: error: 'ans' was not declared in this scope; did you mean 'abs'? 43 | if(ans[80] != 0){ | ^~~ | abs a.cc: At global scope: a.cc:56:1: error: expected declaration before '}' token 56 | } | ^
s257859340
p00015
C++
#include <stdio.h> #include <string.h> int main(void) { unsigned char num1[100],num2[100]; int ia,ib,i,j,k,l,num,ex,large,small; int size1,size2; int sum[100]; scanf("%d",&num);//????????????????????° for (l = 0; l < num; ++l) { scanf("%s",num1); scanf("%s",num2); size1 = strlen(num1); size2 = strlen(num2); if (size2 >= size1)// ???>??????????????¨?????????????????°??? { large = (size2 - 1); small = (size1 - 1); } else if (size1 >= size2) { large = (size1 - 1); small = (size2 - 1); } //80?????\?????§overflow if (large > 80) { printf("overflow\n"); continue; } //num1?????°?????????????????????****************************************** for(ia = 0; ia < 100; ia++) { if(num1[ia+1] == '\0')break; //NULL????????????????????????????????? ex = num1[ia]; num1[ia] = num1[ia+1]; num1[ia+1] = ex; } for (j = ia; j > 0 ; --j) //ia?????????????????§??????????????£?????? { for (k = 0; k < j-1; ++k) //????????????????????????????????£?????? //??????????????¨??????????????? ?????????????????§ { ex = num1[k]; num1[k] = num1[k+1]; num1[k+1] = ex; } } j=0; k=0; //num2?????°?????????????????????****************************************** for(ib = 0; ib < 100; ib++) { if(num2[ib+1] == '\0')break; //NULL????????????????????????????????? ex = num2[ib]; num2[ib] = num2[ib+1]; num2[ib+1] = ex; } for (j = ib; j > 0 ; --j) //ib?????????????????§??????????????£?????? { for (k = 0; k < j-1; ++k) //????????????????????????????????£?????? //??????????????¨??????????????? ?????????????????§ { ex = num2[k]; num2[k] = num2[k+1]; num2[k+1] = ex; } } j=0; k=0; //??±????????????????????\??????????????? //(large???0?????\???????????¨??????????????????????????????) if (ia == 0 && ib == 0) { printf("%d\n", (num1[0]-48) + (num2[0]-48)); continue; } //??°??????????????\??????????????? //??\???????¶???????????????????????????????????????????0???????´? if (ia != ib) { for (j = small + 1; j <= large ; ++j) { if (ia < ib) { num1[j] = '0'; } else if (ib < ia) { num2[j] = '0'; } } } //????????? for (i = 0; i <= large+1; ++i) { sum[i] = 0; } i = 0; for (i = 0; i <= large; ++i) { sum[i] += ((num1[i]-'0') + (num2[i]-'0')); if (sum[i] >= 10)//??????????????¢??¬??§10?¶????????????? { sum[i] -= 10; //??????????????°????????\?????? sum[i+1] += 1;; //??°????????? //(???)80 + 50?????????????????????????????´???????????? if (i == large) { large += 1; break; } } } //?¶????????????????80????¶??????????overflow if (large > 80) { printf("overflow\n"); continue; } for (i = large; i >= 0; --i) { printf("%d", sum[i]); } printf("\n"); i = 0; } return 0; }
a.cc: In function 'int main()': a.cc:18:24: error: invalid conversion from 'unsigned char*' to 'const char*' [-fpermissive] 18 | size1 = strlen(num1); | ^~~~ | | | unsigned char* In file included from a.cc:2: /usr/include/string.h:407:35: note: initializing argument 1 of 'size_t strlen(const char*)' 407 | extern size_t strlen (const char *__s) | ~~~~~~~~~~~~^~~ a.cc:19:24: error: invalid conversion from 'unsigned char*' to 'const char*' [-fpermissive] 19 | size2 = strlen(num2); | ^~~~ | | | unsigned char* /usr/include/string.h:407:35: note: initializing argument 1 of 'size_t strlen(const char*)' 407 | extern size_t strlen (const char *__s) | ~~~~~~~~~~~~^~~
s397491188
p00015
C++
#include <cstdio> #include <cstring> #include <algorithm> const int MAX_SIZE = 90; #define toI(x) (x-'0') using namespace std; class Z { private: int size; char d[MAX_SIZE]; public: Z(char *s) { size = strlen(s); for(int i=0;i<MAX_SIZE - size;i++) d[i] = 0; for(int i=0,j=MAX_SIZE - size;j < MAX_SIZE; i++, j++) d[j] = s[i]; } void add(Z r) { int tmp = max(this->size, r.size); int updigit = 0; for(int i=MAX_SIZE-1;i>=0;i--){ int a = 0, b = 0; if(this->d[i] == 0&& r.d[i] == 0){ if(!updigit) goto end; this->d[i] = updigit+'0'; updigit = 0; tmp++; }else{ if(this->d[i]) a = toI(this->d[i]); if(r.d[i]) b = toI(r.d[i]); int n = a + b + updigit; updigit = n / 10; this->d[i] = (n % 10)+'0'; } } end: this->size = tmp; return; } void print() { if(this->size > 80){ puts("overflow"); return; } for(int i=0;i<MAX_SIZE;i++) if(d[i] != -1) putchar(d[i]); puts(""); } int sz() { return this->size; } }; int main() { /* int x; scanf("%d", &x); char s1[MAX_SIZE], s2[MAX_SIZE]; for(int i=0;i<x;i++){ scanf("%s%s",s1, s2); Z z1(s1); Z z2(s2); if(z1.sz() > 80 || z2.sz() > 80){ puts("overflow"); continue; } z1.add(z2); z1.print();*/ } return 0; }
a.cc:87:3: error: expected unqualified-id before 'return' 87 | return 0; | ^~~~~~ a.cc:88:1: error: expected declaration before '}' token 88 | } | ^
s039314214
p00015
C++
#include <cstdio> #include <cstring> #include <algorithm> #define MAX_SIZE 90; #define toI(x) (x-'0') using namespace std; class Z { private: int size; char d[MAX_SIZE]; public: Z(char *s) { size = strlen(s); for(int i=0;i<MAX_SIZE - size;i++) d[i] = 0; for(int i=0,j=MAX_SIZE - size;j < MAX_SIZE; i++, j++) d[j] = s[i]; } void add(Z r) { int tmp = max(this->size, r.size); int updigit = 0; for(int i=MAX_SIZE-1;i>=0;i--){ int a = 0, b = 0; if(this->d[i] == 0&& r.d[i] == 0){ if(!updigit) goto end; this->d[i] = updigit+'0'; updigit = 0; tmp++; }else{ if(this->d[i]) a = toI(this->d[i]); if(r.d[i]) b = toI(r.d[i]); int n = a + b + updigit; updigit = n / 10; this->d[i] = (n % 10)+'0'; } } end: this->size = tmp; return; } void print() { if(this->size > 80){ puts("overflow"); return; } for(int i=0;i<MAX_SIZE;i++) if(d[i] != -1) putchar(d[i]); puts(""); } int sz() { return this->size; } }; int main() { int x; scanf("%d", &x); char s1[MAX_SIZE], s2[MAX_SIZE]; for(int i=0;i<x;i++){ /* scanf("%s%s",s1, s2); Z z1(s1); Z z2(s2); if(z1.sz() > 80 || z2.sz() > 80){ puts("overflow"); continue; } z1.add(z2); z1.print(); */ } return 0; }
a.cc:5:20: error: expected ']' before ';' token 5 | #define MAX_SIZE 90; | ^ a.cc:15:10: note: in expansion of macro 'MAX_SIZE' 15 | char d[MAX_SIZE]; | ^~~~~~~~ a.cc:15:18: error: expected unqualified-id before ']' token 15 | char d[MAX_SIZE]; | ^ a.cc: In constructor 'Z::Z(char*)': a.cc:20:34: error: expected ')' before ';' token 20 | for(int i=0;i<MAX_SIZE - size;i++) | ^ a.cc:20:8: note: to match this '(' 20 | for(int i=0;i<MAX_SIZE - size;i++) | ^ a.cc:20:35: error: 'i' was not declared in this scope 20 | for(int i=0;i<MAX_SIZE - size;i++) | ^ a.cc:5:20: error: expected ')' before ';' token 5 | #define MAX_SIZE 90; | ^ a.cc:22:39: note: in expansion of macro 'MAX_SIZE' 22 | for(int i=0,j=MAX_SIZE - size;j < MAX_SIZE; i++, j++) | ^~~~~~~~ a.cc:22:8: note: to match this '(' 22 | for(int i=0,j=MAX_SIZE - size;j < MAX_SIZE; i++, j++) | ^ a.cc:22:54: error: 'j' was not declared in this scope 22 | for(int i=0,j=MAX_SIZE - size;j < MAX_SIZE; i++, j++) | ^ a.cc: In member function 'void Z::add(Z)': a.cc:30:30: error: expected ')' before ';' token 30 | for(int i=MAX_SIZE-1;i>=0;i--){ | ^ a.cc:30:8: note: to match this '(' 30 | for(int i=MAX_SIZE-1;i>=0;i--){ | ^ a.cc:30:31: error: 'i' was not declared in this scope 30 | for(int i=MAX_SIZE-1;i>=0;i--){ | ^ a.cc: In member function 'void Z::print()': a.cc:59:27: error: expected primary-expression before ';' token 59 | for(int i=0;i<MAX_SIZE;i++) | ^ a.cc:59:27: error: expected ')' before ';' token a.cc:59:8: note: to match this '(' 59 | for(int i=0;i<MAX_SIZE;i++) | ^ a.cc:59:28: error: 'i' was not declared in this scope 59 | for(int i=0;i<MAX_SIZE;i++) | ^ a.cc: In function 'int main()': a.cc:5:20: error: expected ']' before ';' token 5 | #define MAX_SIZE 90; | ^ a.cc:75:11: note: in expansion of macro 'MAX_SIZE' 75 | char s1[MAX_SIZE], s2[MAX_SIZE]; | ^~~~~~~~ a.cc:75:19: error: expected primary-expression before ']' token 75 | char s1[MAX_SIZE], s2[MAX_SIZE]; | ^ a.cc:75:33: error: expected primary-expression before ']' token 75 | char s1[MAX_SIZE], s2[MAX_SIZE]; | ^
s758459398
p00015
C++
#include <iostream> #include <vector> #include<string> #include<sstream> #define CAPACITY 9 namespace stoi{ int stoi(std::string str){ int ret; std:: stringstream ss; ss << str; ss >> ret; return ret; } } class OverDigit { public: int num_a[CAPACITY]; int num_b[CAPACITY]; OverDigit(std::string str_a, std::string str_b); void ChangeDigit(std::string str,int num[]); void Add(); }; OverDigit::OverDigit(std::string str_a,std::string str_b) { ChangeDigit(str_a, num_a); ChangeDigit(str_b, num_b); } void OverDigit::ChangeDigit(std::string str, int num[]) { td::vector <int> num_str(CAPACITY, 0); int loc = CAPACITY, k = 8; int str_Max, str_rest; str_Max = str.length() / CAPACITY;// str_rest = str.length() % CAPACITY; for (int j = str.length() - CAPACITY; str_Max > 0; j = j-CAPACITY) { num_str[0] = stoi::stoi(str.substr(j, CAPACITY)); loc = k; k--; str_Max--; } if(str_rest!=0) { num_str[loc - 1] = stoi::stoi(str.substr(0, str_rest)); } for (int j = 0; j < CAPACITY; j++) { num[j]=num_str[j]; } } void OverDigit::Add() { int num_ans[CAPACITY] = {}; int fat,overflow=0,count=0; for (int j = CAPACITY-1; j >0; j--) { if (num_a[j] + num_b[j]<=999999999) { num_ans[j] = num_a[j] + num_b[j]; } else if (num_a[j] + num_b[j] > 999999999) { fat = (num_a[j] + num_b[j]) - 1000000000; num_ans[j] = fat; num_a[j - 1]++; } } if (num_a[0] + num_b[0] > 99999999) { overflow = 1; } else { num_ans[0]= num_a[0] + num_b[0]; } if (overflow == 1) { std::cout << "overflow" << std::endl; } else { for (int j = 0; j < CAPACITY; j++) { if (num_ans[j] != 0) { count++; std::cout << num_ans[j]; } else if (num_ans[j] == 0 && count >= 1) { std::cout << "000000000"; } } std::cout << std::endl; } } int main(){ int N; std::string str_a, str_b; std::cin >> N; std::cin.ignore(); for (int i = 0; i < N; i++){ getline(std::cin, str_a); getline(std::cin, str_b); OverDigit OverDigit_a(str_a,str_b); OverDigit_a.Add(); } return 0; }
a.cc: In member function 'void OverDigit::ChangeDigit(std::string, int*)': a.cc:38:1: error: 'td' has not been declared 38 | td::vector <int> num_str(CAPACITY, 0); | ^~ a.cc:38:13: error: expected primary-expression before 'int' 38 | td::vector <int> num_str(CAPACITY, 0); | ^~~ a.cc:48:9: error: 'num_str' was not declared in this scope; did you mean 'num_a'? 48 | num_str[0] = stoi::stoi(str.substr(j, CAPACITY)); | ^~~~~~~ | num_a a.cc:56:17: error: 'num_str' was not declared in this scope; did you mean 'num_a'? 56 | num_str[loc - 1] = stoi::stoi(str.substr(0, str_rest)); | ^~~~~~~ | num_a a.cc:61:24: error: 'num_str' was not declared in this scope; did you mean 'num_a'? 61 | num[j]=num_str[j]; | ^~~~~~~ | num_a
s940903952
p00015
C++
#include <iostream> #include <vector> #include<string> #include<sstream> #define CAPACITY 9 namespace stoi{ int stoi(std::string str){ int ret; std:: stringstream ss; ss << str; ss >> ret; return ret; } } class OverDigit { public: int num_a[CAPACITY]; int num_b[CAPACITY]; OverDigit(std::string str_a, std::string str_b); void ChangeDigit(std::string str,int num[]); void Add(); }; OverDigit::OverDigit(std::string str_a,std::string str_b) { ChangeDigit(str_a, num_a); ChangeDigit(str_b, num_b); } void OverDigit::ChangeDigit(std::string str, int num[]) { std::vector <int> num_str(CAPACITY, 0); int loc = CAPACITY, k = 8; int str_Max, str_rest; str_Max = str.length() / CAPACITY;// str_rest = str.length() % CAPACITY; for (int j = str.length() - CAPACITY; str_Max > 0; j = j-CAPACITY) { num_str[k] = stoi::stoi(str.substr(j, CAPACITY)); loc = k; k--; str_Max--; } if(str_rest!=0) { num_str[loc - 1] = stoi::stoi(str.substr(0, str_rest)); } for (int j = 0; j < CAPACITY; j++) { num[j]=num_str[j]; } } void OverDigit::Add() { int num_ans[CAPACITY] = {}; int fat,overflow=0,count=0; for (int j = CAPACITY-1; j >0; j--) { if (num_a[j] + num_b[j]<=999999999) { num_ans[j] = num_a[j] + num_b[j]; } else if (num_a[j] + num_b[j] > 999999999) { fat = (num_a[j] + num_b[j]) - 1000000000; num_ans[j] = fat; num_a[j - 1]++; } } if (num_a[0] + num_b[0] > 99999999) { overflow = 1; } else { num_ans[0]= num_a[0] + num_b[0]; } if (overflow == 1) { std::cout << "overflow" << std::endl; } else { for (int j = 0; j < CAPACITY; j++) { if (num_ans[j] != 0) { count++; std::cout << num_ans[j]; } else if (num_ans[j] == 0 && count >= 1) { std::cout << "000000000"; } } std::cout << std::endl; } } int main(){ int N; std::string str_a, str_b; std::cin >> N; //std::cin.ignore(); for (int i = 0; i < N; i++) { //getline(std::cin, str_a); //getline(std::cin, str_b); std::cin >> str_a >> str_b; OverDigit OverDigit_a(str_a,str_b); OverDigit_a.Add(); } return 0; } #include <iostream> #include <string> int main() { int N; std::string str_a, str_b; std::cin >> N; std::cin.ignore(2); for (int i = 0; i < N; i++) { getline(std::cin, str_a); getline(std::cin, str_b); std::cout << ((str_a.compare("1000")==0)?"1800":"10000000000000000000000000000000000000000") << std::endl; } return 0; }
a.cc:150:5: error: redefinition of 'int main()' 150 | int main() | ^~~~ a.cc:118:5: note: 'int main()' previously defined here 118 | int main(){ | ^~~~
s789883923
p00015
C++
import std.stdio; import std.string; import std.conv; import std.algorithm; void main(){ int n; readf("%d\n",&n); for(int i=0;i<n;i++){ string s1,s2,res; s1 = chomp(readln()); s2 = chomp(readln()); res = ""; int x = to!int(s1.length-1); int y = to!int(s2.length-1); if( y > x) { swap(s1,s2); swap(x,y); } int add = 0; while(x >= 0 || add > 0){ int sum = 0; if(y >= 0) sum = to!int(s1[x] - '0') + to!int(s2[y] - '0'); else if(x >= 0) sum = to!int(s1[x] - '0'); else sum = 0; if( sum + add > 9){ res = to!string((sum + add)%10) ~ res; add = 1; }else{ res = to!string(sum + add) ~ res; add = 0; } if(x >= 0) x--; if(y >= 0) y--; } writeln(res); } }
a.cc:1:1: error: 'import' does not name a type 1 | import std.stdio; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import std.string; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: 'import' does not name a type 3 | import std.conv; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: 'import' does not name a type 4 | import std.algorithm; | ^~~~~~ a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:6:1: error: '::main' must return 'int' 6 | void main(){ | ^~~~ a.cc: In function 'int main()': a.cc:9:5: error: 'readf' was not declared in this scope 9 | readf("%d\n",&n); | ^~~~~ a.cc:11:9: error: 'string' was not declared in this scope 11 | string s1,s2,res; | ^~~~~~ a.cc:12:9: error: 's1' was not declared in this scope 12 | s1 = chomp(readln()); | ^~ a.cc:12:20: error: 'readln' was not declared in this scope 12 | s1 = chomp(readln()); | ^~~~~~ a.cc:12:14: error: 'chomp' was not declared in this scope 12 | s1 = chomp(readln()); | ^~~~~ a.cc:13:9: error: 's2' was not declared in this scope 13 | s2 = chomp(readln()); | ^~ a.cc:14:9: error: 'res' was not declared in this scope 14 | res = ""; | ^~~ a.cc:15:17: error: 'to' was not declared in this scope 15 | int x = to!int(s1.length-1); | ^~ a.cc:18:13: error: 'swap' was not declared in this scope 18 | swap(s1,s2); | ^~~~ a.cc:40:9: error: 'writeln' was not declared in this scope 40 | writeln(res); | ^~~~~~~
s356296716
p00015
C++
import std.stdio; import std.string; import std.conv; import std.algorithm; void main(){ int n; readf("%d\n",&n); for(int i=0;i<n;i++){ string s1,s2,res; s1 = chomp(readln()); s2 = chomp(readln()); res = ""; int x = to!int(s1.length-1); int y = to!int(s2.length-1); if( y > x) { swap(s1,s2); swap(x,y); } int add = 0; while(x >= 0 || add > 0){ int sum = 0; if(y >= 0) sum = to!int(s1[x] - '0') + to!int(s2[y] - '0'); else if(x >= 0) sum = to!int(s1[x] - '0'); else sum = 0; if( sum + add > 9){ res = to!string((sum + add)%10) ~ res; add = 1; }else{ res = to!string(sum + add) ~ res; add = 0; } if(x >= 0) x--; if(y >= 0) y--; } if(res.length > 80) writef("overflow");//writeln("overflow"); else writef("%s\n",res);//writeln(res); } }
a.cc:1:1: error: 'import' does not name a type 1 | import std.stdio; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import std.string; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: 'import' does not name a type 3 | import std.conv; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: 'import' does not name a type 4 | import std.algorithm; | ^~~~~~ a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:6:1: error: '::main' must return 'int' 6 | void main(){ | ^~~~ a.cc: In function 'int main()': a.cc:9:5: error: 'readf' was not declared in this scope 9 | readf("%d\n",&n); | ^~~~~ a.cc:11:9: error: 'string' was not declared in this scope 11 | string s1,s2,res; | ^~~~~~ a.cc:12:9: error: 's1' was not declared in this scope 12 | s1 = chomp(readln()); | ^~ a.cc:12:20: error: 'readln' was not declared in this scope 12 | s1 = chomp(readln()); | ^~~~~~ a.cc:12:14: error: 'chomp' was not declared in this scope 12 | s1 = chomp(readln()); | ^~~~~ a.cc:13:9: error: 's2' was not declared in this scope 13 | s2 = chomp(readln()); | ^~ a.cc:14:9: error: 'res' was not declared in this scope 14 | res = ""; | ^~~ a.cc:15:17: error: 'to' was not declared in this scope 15 | int x = to!int(s1.length-1); | ^~ a.cc:18:13: error: 'swap' was not declared in this scope 18 | swap(s1,s2); | ^~~~ a.cc:40:29: error: 'writef' was not declared in this scope 40 | if(res.length > 80) writef("overflow");//writeln("overflow"); | ^~~~~~ a.cc:41:14: error: 'writef' was not declared in this scope 41 | else writef("%s\n",res);//writeln(res); | ^~~~~~
s057987270
p00015
C++
n = int(input()) for i in range(n): a = int(input()) b = int(input()) print(a + b)
a.cc:1:1: error: 'n' does not name a type 1 | n = int(input()) | ^
s610345788
p00015
C++
def first_digit(n) n[0] end def digit(n) n.size end def overflow?(a, b) if digit(a) > 80 || digit(b) > 80 puts 'overflow' return true end if digit(a) == 80 && digit(b) == 80 if [a, b].map { |e| first_digit(e).to_i }.inject(:+) >= 10 puts 'overflow' return true end end false end input = STDIN.read.split("\n").map(&:chomp) input.shift.to_i.times do a = input.shift b = input.shift next if overflow?(a, b) puts [a, b].map(&:to_i).inject(:+) end
a.cc:11:10: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes 11 | puts 'overflow' | ^~~~~~~~~~ a.cc:17:12: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes 17 | puts 'overflow' | ^~~~~~~~~~ a.cc:1:1: error: 'def' does not name a type 1 | def first_digit(n) | ^~~ a.cc:16:46: error: expected unqualified-id before '.' token 16 | if [a, b].map { |e| first_digit(e).to_i }.inject(:+) >= 10 | ^
s963897171
p00015
C++
#include <string> using namespace std; int main(){ int n,i,j; string a,b; int sum[110]={}; int up = 0; cin >> n; for(i=0;i<n;i++){ cin >> a >> b; int sa=a.size(),sb=b.size(); int flag=0; if(sa>=80||sb>=80) flag =1; for(j=0;j<max(sa,sb);j++){ if(sa>j&&sb>j){ sum[j] = (a[sa-j-1]-'0') + (b[sb-j-1]-'0') + up; }else if(sa>j){ sum[j] = (a[sa-j-1]-'0') + up; }else if(sb>j){ sum[j] = (b[sb-j-1]-'0') + up; } up=0; if(sum[j]>9){ up=1; sum[j]-=10; } } sum[max(sa,sb)]=up; int k=110-1; while(sum[k]==0&&k>0) k--; if(k>=80||flag==1) cout << "overflow"; else for(j=k;j>=0;j--) cout << sum[j]; cout << endl; } }
a.cc: In function 'int main()': a.cc:10:3: error: 'cin' was not declared in this scope 10 | cin >> n; | ^~~ a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 1 | #include <string> +++ |+#include <iostream> 2 | using namespace std; a.cc:33:24: error: 'cout' was not declared in this scope 33 | if(k>=80||flag==1) cout << "overflow"; | ^~~~ a.cc:33:24: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:36:7: error: 'cout' was not declared in this scope 36 | cout << sum[j]; | ^~~~ a.cc:36:7: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:37:5: error: 'cout' was not declared in this scope 37 | cout << endl; | ^~~~ a.cc:37:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:37:13: error: 'endl' was not declared in this scope 37 | cout << endl; | ^~~~ a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 1 | #include <string> +++ |+#include <ostream> 2 | using namespace std;
s005341459
p00015
C++
include <iostream> #include <cmath> #include <vector> using namespace std; int main(){ int num; cin >> num; vector<int> LONGINT(num, 0); long long int larger; // 8????????? long long int smaller; // 8????????? int sum = 0; while(true){ larger = 0; smaller = 0; for(int i=0;i<num;i++){ cin >> LONGINT[i]; // ???8???????????????. smaller += (long long int)(LONGINT[i]%(int)pow(10.0, 8.0)); larger += (long long int)(LONGINT[i]/(int)pow(10.0,8.0)); } larger += smaller/pow(10,8); smaller = smaller%(int)pow(10,8); if(larger!=0){ cout << larger << smaller << endl; } } }
a.cc:1:1: error: 'include' does not name a type 1 | include <iostream> | ^~~~~~~ In file included from /usr/include/c++/14/cmath:45, from a.cc:2: /usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity 164 | __is_null_pointer(std::nullptr_t) | ^ /usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)' 159 | __is_null_pointer(_Type) | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std' 164 | __is_null_pointer(std::nullptr_t) | ^~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/bits/specfun.h:43, from /usr/include/c++/14/cmath:3906: /usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std' 666 | struct is_null_pointer<std::nullptr_t> | ^~~~~~~~~ /usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid 666 | struct is_null_pointer<std::nullptr_t> | ^ /usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid 670 | struct is_null_pointer<const std::nullptr_t> | ^ /usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid 674 | struct is_null_pointer<volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid 678 | struct is_null_pointer<const volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ In file included from /usr/include/stdlib.h:32, from /usr/include/c++/14/bits/std_abs.h:38, from /usr/include/c++/14/cmath:49: /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^ /usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid 1438 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared 1440 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope 1441 | struct rank<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid 1441 | struct rank<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared 2086 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope 2087 | struct remove_extent<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid 2087 | struct remove_extent<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared 2099 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope 2100 | struct remove_all_extents<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid 2100 | struct remove_all_extents<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared 2171 | template<std::size_t _Len> | ^~~ /usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope 2176 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^~~~ /usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^ /usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope 2202 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope 2203 | struct __attribute__((__aligned__((_Align)))) { } __align; | ^~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:65: /usr/include/c++/14/bits/stl_iterator_base_types.h:125:67: error: 'ptrdiff_t' does not name a type 125 | template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t, | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_types.h:1:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' +++ |+#include <cstddef> 1 | // Types used in iterator implementation -*- C++ -*- /usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: error: 'ptrdiff_t' does not name a type 214 | typedef ptrdiff_t difference_type; | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: error: 'ptrdiff_t' does not name a type 225 | typedef ptrdiff_t difference_type; | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' In file included from /usr/include/c++/14/bits/stl_algobase.h:66: /usr/include/c++/14/bits/stl_iterator_base_funcs.h:112:5: error: 'ptrdiff_t' does not name a type 112 | ptrdiff_t | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:66:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 65 | #include <debug/assertions.h> +++ |+#include <cstddef> 66 | #include <bits/stl_iterator_base_types.h> /usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: error: 'ptrdiff_t' does not name a type 118 | ptrdiff_t | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' In file included from /usr/include/c++/14/bits/stl_iterator.h:67, from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bit
s449460009
p00015
C++
#include <stdio.h> #include <string.h> int chomp(char *str){ int len = strlen(str); if(str[len-1]=='\n'){ str[len-1] = '\0'; len--; } return len; } int main(){ int n; int i,j; int s1,s2,la,sm; char a1[103],a2[103],*pla,*psm,dummy[2]; int carry,r; scanf("%d",&n); fgets(dummy,2,stdin); for(i=0;i<n;i++){ fgets(a1,103,stdin); fgets(a2,103,stdin); s1 = chomp(a1); s2 = chomp(a2); if(s1>80||s2>80){ printf("overflow\n"); next; } if(s1<s2){ pla = a2; la = s2; psm = a1; sm = s1; }else{ pla = a1; la = s1; psm = a2; sm = s2; } carry = 0; for(j=0;j<la;j++){ r = (j<sm) ? (psm[sm-j-1]-'0') : 0; r += (pla[la-j-1]-'0')+carry; carry = r/10; pla[la-j] = '0' + r%10; } if(carry){ pla[0] = '1'; }else{ pla = (s1<s2) ? &a2[1] : &a1[1]; } if(j+carry>80){ printf("overflow\n"); next; } printf("%s\n",pla); } }
a.cc: In function 'int main()': a.cc:28:13: error: 'next' was not declared in this scope 28 | next; | ^~~~ a.cc:55:17: error: 'next' was not declared in this scope 55 | next; | ^~~~
s060626981
p00015
C++
#include<iostream> using namespace std; int main(){ int cnt, m; cin >> cnt; string s1, s2, ans; for(int i = 0; i < cnt; i++){ cin >> s1 >> s2; ans = ""; m = max(s1.size(), ans.size()); while( s1.size() < m ) s1 = '0' + s1; while( s2.size() < m ) s2 = '0' + s2; int c = 0; for(int i = m-1; i >= 0; i--){ char ch = ((s1[i] - '0') + (s2[i] - '0') + c) % 10 + '0'; c = ((s1[i] - '0') + (s2[i] - '0') + c) / 10; ans += ch; } if(c) ans += c + '0'; reverse(ans.begin(), ans.end()); while(ans.size() > 1 && ans[0] == '0') ans.erase(ans.begin()); if(ans.size() > 80) cout << "overflow" << endl; else cout << ans << endl; } }
a.cc: In function 'int main()': a.cc:23:17: error: 'reverse' was not declared in this scope 23 | reverse(ans.begin(), ans.end()); | ^~~~~~~
s714066160
p00015
C++
#include "bits/stdc++.h" #define debug(x) cout<<#x<<": "<<x<<endl #define rep(i,n) for (int i=0;i<(n);i++) #define FOR(i,a,b) for (int i=(a);i<=(b);i++) #define all(a) (a).begin(),(a).end() using namespace std; typedef vector<int> VI; typedef vector<vector<int>> VVI; typedef long long ll; ll gcd(ll a, ll b) { ll c; while (a != 0) { c = a; a = b%a; b = c; } return b; } void solve() { #ifdef _WIN32 istream &cin = ifstream("input.txt"); #endif int n; cin >> n; rep(i, n) { vector<ll> v1(11), v2(11); string s1, s2; cin >> s1 >> s2; rep(j, 10) { if (s1.size() > 10 * j) v1[j] = stoi(s1.substr(10 * j, min(10u, s1.size() - 10 * j))); if (s2.size() > 10 * j) v2[j] = stoi(s2.substr(10 * j, min(10u, s2.size() - 10 * j))); } rep(j, 11) { v1[j] += v2[j]; if (v1[j] >= 1e10) { v1[j] -= 1e10; v2[j]++; } } if (v1[8] || v1[9] || v1[10]) cout << "overflow" << endl; else { rep(j, 11) if (v1[10 - j] != 0) cout << v1[10 - j]; cout << endl; } } } int main() { cin.tie(0); ios::sync_with_stdio(false); solve(); system("PAUSE"); return 0; }
a.cc: In function 'void solve()': a.cc:30:83: error: no matching function for call to 'min(unsigned int, std::__cxx11::basic_string<char>::size_type)' 30 | if (s1.size() > 10 * j) v1[j] = stoi(s1.substr(10 * j, min(10u, s1.size() - 10 * j))); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:30:83: note: deduced conflicting types for parameter 'const _Tp' ('unsigned int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'}) 30 | if (s1.size() > 10 * j) v1[j] = stoi(s1.substr(10 * j, min(10u, s1.size() - 10 * j))); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:30:83: note: mismatched types 'std::initializer_list<_Tp>' and 'unsigned int' 30 | if (s1.size() > 10 * j) v1[j] = stoi(s1.substr(10 * j, min(10u, s1.size() - 10 * j))); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:31:83: error: no matching function for call to 'min(unsigned int, std::__cxx11::basic_string<char>::size_type)' 31 | if (s2.size() > 10 * j) v2[j] = stoi(s2.substr(10 * j, min(10u, s2.size() - 10 * j))); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:31:83: note: deduced conflicting types for parameter 'const _Tp' ('unsigned int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'}) 31 | if (s2.size() > 10 * j) v2[j] = stoi(s2.substr(10 * j, min(10u, s2.size() - 10 * j))); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:31:83: note: mismatched types 'std::initializer_list<_Tp>' and 'unsigned int' 31 | if (s2.size() > 10 * j) v2[j] = stoi(s2.substr(10 * j, min(10u, s2.size() - 10 * j))); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
s880489104
p00015
C++
#include<iostream> using namespace std; string solve(string s1, string s2){ while(s1.size()<85){ s1 = '0' + s1; } while(s2.size()<85){ s2 = '0' + s2; } string ret = ""; int kuri = 0; for(int i=0;i<80;i++){ int r = (int)(s1[s1.size()-1-i]-'0' + s2[s2.size()-1-i]-'0') + kuri; kuri = r/10; r = r%10; ret = ((char)('0'+r)) + ret; } if (kuri>0) return "overflow"; else return ret; } int main(void){ int N; cin >> N; for(int i=0i<N;i++){ string s1, s2; cin >> s1 >> s2; cout << solve(s1, s2) << endl; } return 0; }
a.cc: In function 'int main()': a.cc:28:13: error: invalid operands of types '__complex__ int' and 'int' to binary 'operator<' 28 | for(int i=0i<N;i++){ a.cc:28:19: error: expected ';' before ')' token 28 | for(int i=0i<N;i++){ | ^ | ;
s298961713
p00015
C++
#include<bits/stdc++.h> using namespace std; string solve(string s1, string s2){ while(s1.size()<85){ s1 = '0' + s1; } while(s2.size()<85){ s2 = '0' + s2; } string ret = ""; int kuri = 0; for(int i=0;i<80;i++){ int r = (int)(s1[s1.size()-1-i]-'0' + s2[s2.size()-1-i]-'0') + kuri; kuri = r/10; r = r%10; ret = ((char)('0'+r)) + ret; } if (kuri>0) return "overflow"; else return ret; } int main(void){ int N; cin >> N; for(int i=0i<N;i++){ string s1, s2; cin >> s1 >> s2; cout << solve(s1, s2) << endl; } return 0; }
a.cc: In function 'int main()': a.cc:27:13: error: no match for 'operator<' (operand types are 'std::complex<double>' and 'int') 27 | for(int i=0i<N;i++){ | ~~^~ | | | | | int | std::complex<double> In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181, from a.cc:1: /usr/include/c++/14/bits/regex.h:1143:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1143 | operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1143:5: note: template argument deduction/substitution failed: a.cc:27:14: note: 'std::complex<double>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 27 | for(int i=0i<N;i++){ | ^ /usr/include/c++/14/bits/regex.h:1224:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1224 | operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1224:5: note: template argument deduction/substitution failed: a.cc:27:14: note: 'std::complex<double>' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' 27 | for(int i=0i<N;i++){ | ^ /usr/include/c++/14/bits/regex.h:1317:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1317 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1317:5: note: template argument deduction/substitution failed: a.cc:27:14: note: 'std::complex<double>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 27 | for(int i=0i<N;i++){ | ^ /usr/include/c++/14/bits/regex.h:1391:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1391 | operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1391:5: note: template argument deduction/substitution failed: a.cc:27:14: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int' 27 | for(int i=0i<N;i++){ | ^ /usr/include/c++/14/bits/regex.h:1485:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1485 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1485:5: note: template argument deduction/substitution failed: a.cc:27:14: note: 'std::complex<double>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 27 | for(int i=0i<N;i++){ | ^ /usr/include/c++/14/bits/regex.h:1560:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1560 | operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1560:5: note: template argument deduction/substitution failed: a.cc:27:14: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int' 27 | for(int i=0i<N;i++){ | ^ /usr/include/c++/14/bits/regex.h:1660:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1660 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1660:5: note: template argument deduction/substitution failed: a.cc:27:14: note: 'std::complex<double>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 27 | for(int i=0i<N;i++){ | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: a.cc:27:14: note: 'std::complex<double>' is not derived from 'const std::pair<_T1, _T2>' 27 | for(int i=0i<N;i++){ | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: a.cc:27:14: note: 'std::complex<double>' is not derived from 'const std::reverse_iterator<_Iterator>' 27 | for(int i=0i<N;i++){ | ^ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: a.cc:27:14: note: 'std::complex<double>' is not derived from 'const std::reverse_iterator<_Iterator>' 27 | for(int i=0i<N;i++){ | ^ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed: a.cc:27:14: note: 'std::complex<double>' is not derived from 'const std::move_iterator<_IteratorL>' 27 | for(int i=0i<N;i++){ | ^ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1760 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed: a.cc:27:14: note: 'std::complex<double>' is not derived from 'const std::move_iterator<_IteratorL>' 27 | for(int i=0i<N;i++){ | ^ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 673 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed: a.cc:27:14: note: 'std::complex<double>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 27 | for(int i=0i<N;i++){ | ^ /usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 680 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed: a.cc:27:14: note: 'std::complex<double>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 27 | for(int i=0i<N;i++){ | ^ /usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:688:5: note: template argument deduction/substitution failed: a.cc:27:14: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int' 27 | for(int i=0i<N;i++){ | ^ /usr/include/c++/14/bits/basic_string.h:3874:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3874 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3874:5: note: template argument deduction/substitution failed: a.cc:27:14: note: 'std::complex<double>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 27 | for(int i=0i<N;i++){ | ^ /usr/include/c++/14/bits/basic_string.h:3888:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3888 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3888:5: note: template argument deduction/substitution failed: a.cc:27:14: note: 'std::complex<double>' is not derived from 'con
s343810378
p00015
C++
#include<algorithm> #include<iostream> #include<cstdio> #include<stdio.h> #include<string> #include<string.h> #include"stdafx.h" using namespace std; int main() { char a1,a2 ; long long a, b,c; int kaisu = 0; cin >> kaisu; for (int i = 0; i < kaisu; i++) { cin >> a; cin >> b; a1 = GetDigit(a); a2 = GetDigit(a); if (a1 + a2 >= 80) { printf("overflow"); } else { c = a + b; printf(c + "\n"); } } return 0; } unsigned GetDigit(unsigned num) { return std::to_string(num).length(); }
a.cc:7:9: fatal error: stdafx.h: No such file or directory 7 | #include"stdafx.h" | ^~~~~~~~~~ compilation terminated.
s086560363
p00015
C++
#include<algorithm> #include<iostream> #include<cstdio> #include<stdio.h> #include<string> #include<string.h> //#include"stdafx.h" using namespace std; int main() { char a1,a2 ; long long a, b,c; int kaisu = 0; cin >> kaisu; for (int i = 0; i < kaisu; i++) { cin >> a; cin >> b; a1 = GetDigit(a); a2 = GetDigit(a); if (a1 + a2 >= 80) { printf("overflow"); } else { c = a + b; printf(c + "\n"); } } return 0; } unsigned GetDigit(unsigned num) { return std::to_string(num).length(); }
a.cc: In function 'int main()': a.cc:20:23: error: 'GetDigit' was not declared in this scope 20 | a1 = GetDigit(a); | ^~~~~~~~
s320502276
p00015
C++
#include <iostream> #include <stdio.h> #include <string.h> #include <string> #define MAX_LEN 101 using namespace std; void q15() { int N; scanf("%d\n", &N); for (int n = 0; n < N; n++) { string a, b; getline(cin, a); getline(cin, b); if (a.length() < b.length()) { string tmp = a; a = b; b = tmp; } reverse(a.begin(), a.end()); reverse(b.begin(), b.end()); int carry = 0; string ans=""; int i = 0; for (; i < b.length(); i++) { ans+= (((a[i] - '0') + (b[i] - '0') + carry) % 10) + '0'; carry = ((a[i] - '0') + (b[i] - '0') + carry) / 10; } for (; i < a.length(); i++) { ans+= (((a[i] - '0') + carry) % 10) + '0'; carry = ((a[i] - '0') + carry) / 10; } for (; carry; i++) { ans+= (carry % 10) + '0'; carry = carry / 10; } reverse(ans.begin(), ans.end()); cout << (ans.length() > 80 ? "overflow" : ans) << endl; } } int main() { q15(); return 0; }
a.cc: In function 'void q15()': a.cc:23:17: error: 'reverse' was not declared in this scope 23 | reverse(a.begin(), a.end()); | ^~~~~~~
s356947117
p00015
C++
#include<iostream> #include<string> #include<algorithm> using namespace std; string plus(string,string); void turn(string &); int main(){ int n; cin>>n; for(int i=0;i<n;++i){ string str,sts; cin>>str>>sts; cout<<plus(str,sts)<<endl; } return 0; } string plus(string str,string sts){ turn(str); turn(sts); while(str.size()!=sts.size()){ if(str.size()<sts.size()){ str+='0'; }else{ sts+='0'; } } str+='0'; sts+='0'; for(int i=0;i<str.size()-1;++i){ str[i]+=sts[i]-'0'; while(str[i]>'9'){ ++str[i+1]; str[i]-=10; } } if(str.back()=='0'){ str.pop_back(); } if(str.size()>80){ return "overflow"; } turn(str); return str; } void turn(string &str){ for(int i=0;i<str.size()/2;++i){ swap(str[i],str[str.size()-i-1]); } }
a.cc: In function 'int main()': a.cc:14:23: error: reference to 'plus' is ambiguous 14 | cout<<plus(str,sts)<<endl; | ^~~~ In file included from /usr/include/c++/14/string:49, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_function.h:160:12: note: candidates are: 'template<class _Tp> struct std::plus' 160 | struct plus; | ^~~~ a.cc:6:8: note: 'std::string plus(std::string, std::string)' 6 | string plus(string,string); | ^~~~
s077650666
p00015
C++
#include <iostream> using namespace std; int main(int argc, char* argv[]) { int i; int num, pos; int len1, len2; char temp; char f1[101] = { 0 }, f2[101] = { 0 }; int up[100] = { 0 }; int sum[101] = { 0 }; cin >> num; while (num--) { cin >> f1; cin >> f2; len1 = strlen(f1); len2 = strlen(f2); if (len1 > 80 || len2 > 80) { cout << "overflow" << endl; continue; } for (int i = 0; i < len1 / 2; i++) { temp = f1[i]; f1[i] = f1[len1 - 1 - i]; f1[len1 - 1 - i] = temp; } for (int i = 0; i < len2 / 2; i++) { temp = f2[i]; f2[i] = f2[len2 - 1 - i]; f2[len2 - 1 - i] = temp; } for (i = 0; i < len1; i++) f1[i] = f1[i] - 0x30; for (i = 0; i < len2; i++) f2[i] = f2[i] - 0x30; for (int i = 0; i < 100; i++) { sum[i] += (f1[i] + f2[i]); if (sum[i] >= 10) { sum[i] -= 10; sum[i + 1]++; } } for (pos = 100; sum[pos] == 0; pos--) {} if (pos >= 80) { cout << "overflow"; break; } for (int i = pos; i >= 0; i--) { cout << sum[i]; } cout << endl; } }
a.cc: In function 'int main(int, char**)': a.cc:20:24: error: 'strlen' was not declared in this scope 20 | len1 = strlen(f1); | ^~~~~~ a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <iostream> +++ |+#include <cstring> 2 |
s163625839
p00015
C++
#include <iostream> using namespace std; int main(int argc, char* argv[]) { int i; int num, pos; int len1, len2; int sum[101] = { 0 }; char temp; char f1[101] = { 0 }, f2[101] = { 0 }; cin >> num; while (num--) { cin >> f1; cin >> f2; len1 = strlen(f1); len2 = strlen(f2); if (len1 > 80 || len2 > 80) { cout << "overflow" << endl; continue; } for (int i = 0; i < len1 / 2; i++) { temp = f1[i]; f1[i] = f1[len1 - 1 - i]; f1[len1 - 1 - i] = temp; } for (int i = 0; i < len2 / 2; i++) { temp = f2[i]; f2[i] = f2[len2 - 1 - i]; f2[len2 - 1 - i] = temp; } for (i = 0; i < len1; i++) f1[i] = f1[i] - 0x30; for (i = 0; i < len2; i++) f2[i] = f2[i] - 0x30; for (int i = 0; i < 100; i++) { sum[i] += (f1[i] + f2[i]); if (sum[i] >= 10) { sum[i] -= 10; sum[i + 1]++; } } for (pos = 100; sum[pos] == 0; pos--) {} if (pos >= 80) { cout << "overflow" << endl; return 0; } for (int i = pos; i >= 0; i--) { cout << sum[i]; } cout << endl; } }
a.cc: In function 'int main(int, char**)': a.cc:19:24: error: 'strlen' was not declared in this scope 19 | len1 = strlen(f1); | ^~~~~~ a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <iostream> +++ |+#include <cstring> 2 |
s983138835
p00015
C++
#include<iostream> #include<cstdlib> #include<string> char iota(int n){ switch (n) { case 0: return '0'; case 1: return '1'; case 2: return '2'; case 3: return '3'; case 4: return '4'; case 5: return '5'; case 6: return '6'; case 7: return '7'; case 8: return '8'; case 9: return '9'; } return '0'; } int main(){ std::string num1; std::string num2; char sum[102]; int n,temp,flag=0,j; const char one = '1'; std::cin >> n; for(int i=0;i<n;i++){ std::cin >> num1 >> num2; if(num1.size()<num2.size()){ num1.swap(num2); } std::reverse(num1.begin(),num1.end()); std::reverse(num2.begin(),num2.end()); for(j=0;j<num2.size();j++){ //std::cout << 1; temp = (num1[j] - '0') + (num2[j] - '0'); if(flag){ temp +=1; flag = 0; } if(temp > 9){ temp -= 10; flag = 1; } sum[j] = iota(temp); //std::cout << temp << std::endl; } while(j<num1.size()){ temp = num1[j] = '0'; if(flag){ temp += 1; flag = 0; } if(temp > 9){ temp -= 10; flag = 1; } sum[j] = iota(temp); } if(flag){ sum[j] = (char)one; sum[j+1] = '\0'; }else{ sum[j] = '\0'; } std::string ssum = std::string(sum); //std::reverse(num1.begin(),num1.end()); //std::reverse(num2.begin(),num2.end()); std::reverse(ssum.begin(),ssum.end()); //std::cout << num1 << std::endl; //std::cout << num2 << std::endl; std::cout << ssum << std::endl; } }
a.cc: In function 'int main()': a.cc:36:10: error: 'reverse' is not a member of 'std' 36 | std::reverse(num1.begin(),num1.end()); | ^~~~~~~ a.cc:37:10: error: 'reverse' is not a member of 'std' 37 | std::reverse(num2.begin(),num2.end()); | ^~~~~~~ a.cc:74:10: error: 'reverse' is not a member of 'std' 74 | std::reverse(ssum.begin(),ssum.end()); | ^~~~~~~
s193479346
p00015
C++
#include<iostream> #include<string> char iota(int n){ switch (n) { case 0: return '0'; case 1: return '1'; case 2: return '2'; case 3: return '3'; case 4: return '4'; case 5: return '5'; case 6: return '6'; case 7: return '7'; case 8: return '8'; case 9: return '9'; } return '0'; } int main(){ std::string num1; std::string num2; char sum[102]; int n,temp,flag=0,j; const char one = '1'; std::cin >> n; for(int i=0;i<n;i++){ std::cin >> num1 >> num2; if(num1.size()<num2.size()){ num1.swap(num2); } std::reverse(num1.begin(),num1.end()); std::reverse(num2.begin(),num2.end()); for(j=0;j<num2.size();j++){ //std::cout << 1; temp = (num1[j] - '0') + (num2[j] - '0'); if(flag){ temp +=1; flag = 0; } if(temp > 9){ temp -= 10; flag = 1; } sum[j] = iota(temp); //std::cout << temp << std::endl; } while(j<num1.size()){ temp = num1[j] = '0'; if(flag){ temp += 1; flag = 0; } if(temp > 9){ temp -= 10; flag = 1; } sum[j] = iota(temp); } if(flag){ sum[j] = (char)one; sum[j+1] = '\0'; }else{ sum[j] = '\0'; } std::string ssum = std::string(sum); //std::reverse(num1.begin(),num1.end()); //std::reverse(num2.begin(),num2.end()); std::reverse(ssum.begin(),ssum.end()); //std::cout << num1 << std::endl; //std::cout << num2 << std::endl; std::cout << ssum << std::endl; } }
a.cc: In function 'int main()': a.cc:35:10: error: 'reverse' is not a member of 'std' 35 | std::reverse(num1.begin(),num1.end()); | ^~~~~~~ a.cc:36:10: error: 'reverse' is not a member of 'std' 36 | std::reverse(num2.begin(),num2.end()); | ^~~~~~~ a.cc:73:10: error: 'reverse' is not a member of 'std' 73 | std::reverse(ssum.begin(),ssum.end()); | ^~~~~~~
s993255069
p00015
C++
#include<iostream> #include<string> char iota(int n){ switch (n) { case 0: return '0'; case 1: return '1'; case 2: return '2'; case 3: return '3'; case 4: return '4'; case 5: return '5'; case 6: return '6'; case 7: return '7'; case 8: return '8'; case 9: return '9'; } return '0'; } int main(){ std::string num1; std::string num2; char sum[102]; int n,temp,flag=0,j; const char one = '1'; std::cin >> n; for(int i=0;i<n;i++){ std::cin >> num1 >> num2; if(num1.size()<num2.size()){ num1.swap(num2); } std::reverse(num1.begin(),num1.end()); std::reverse(num2.begin(),num2.end()); for(j=0;j<num2.size();j++){ //std::cout << 1; temp = (num1[j] - '0') + (num2[j] - '0'); if(flag){ temp +=1; flag = 0; } if(temp > 9){ temp -= 10; flag = 1; } sum[j] = iota(temp); //std::cout << temp << std::endl; } while(j<num1.size()){ temp = num1[j] = '0'; if(flag){ temp += 1; flag = 0; } if(temp > 9){ temp -= 10; flag = 1; } sum[j] = iota(temp); } if(flag){ sum[j] = (char)one; sum[j+1] = '\0'; }else{ sum[j] = '\0'; } std::string ssum = std::string(sum); //reverse(num1.begin(),num1.end()); //reverse(num2.begin(),num2.end()); reverse(ssum.begin(),ssum.end()); //std::cout << num1 << std::endl; //std::cout << num2 << std::endl; std::cout << ssum << std::endl; } }
a.cc: In function 'int main()': a.cc:35:10: error: 'reverse' is not a member of 'std' 35 | std::reverse(num1.begin(),num1.end()); | ^~~~~~~ a.cc:36:10: error: 'reverse' is not a member of 'std' 36 | std::reverse(num2.begin(),num2.end()); | ^~~~~~~ a.cc:73:5: error: 'reverse' was not declared in this scope 73 | reverse(ssum.begin(),ssum.end()); | ^~~~~~~
s362986900
p00015
C++
#include<iostream> #include<string> char iota(int n){ switch (n) { case 0: return '0'; case 1: return '1'; case 2: return '2'; case 3: return '3'; case 4: return '4'; case 5: return '5'; case 6: return '6'; case 7: return '7'; case 8: return '8'; case 9: return '9'; } return '0'; } int main(){ std::string num1; std::string num2; char sum[102]; int n,temp,flag=0,j; const char one = '1'; std::cin >> n; for(int i=0;i<n;i++){ std::cin >> num1 >> num2; if(num1.size()<num2.size()){ num1.swap(num2); } std::reverse(num1.begin(),num1.end()); std::reverse(num2.begin(),num2.end()); for(j=0;j<num2.size();j++){ //std::cout << 1; temp = (num1[j] - '0') + (num2[j] - '0'); if(flag){ temp +=1; flag = 0; } if(temp > 9){ temp -= 10; flag = 1; } sum[j] = iota(temp); //std::cout << temp << std::endl; } while(j<num1.size()){ temp = num1[j] = '0'; if(flag){ temp += 1; flag = 0; } if(temp > 9){ temp -= 10; flag = 1; } sum[j] = iota(temp); } if(flag){ sum[j] = (char)one; sum[j+1] = '\0'; }else{ sum[j] = '\0'; } std::string ssum = std::string(sum); //reverse(num1.begin(),num1.end()); //reverse(num2.begin(),num2.end()); reverse(ssum.begin(),ssum.end()); //std::cout << num1 << std::endl; //std::cout << num2 << std::endl; std::cout << ssum << std::endl; } }
a.cc: In function 'int main()': a.cc:35:10: error: 'reverse' is not a member of 'std' 35 | std::reverse(num1.begin(),num1.end()); | ^~~~~~~ a.cc:36:10: error: 'reverse' is not a member of 'std' 36 | std::reverse(num2.begin(),num2.end()); | ^~~~~~~ a.cc:73:5: error: 'reverse' was not declared in this scope 73 | reverse(ssum.begin(),ssum.end()); | ^~~~~~~
s084421578
p00015
C++
#include<iostream> #include<string> int main(){ std::string as; std::string bs; int a[102]={0}; int b[102]={0}; int sum[102]={0}; int a_size,b_size,sum_size,n,i,j,flag=0; char num; std::cin >> n; for(i=0;i<n;i++){ std::cin >> as >> bs; a_size = as.size(); b_size = bs.size(); for(j=0;j<102;j++){ //??????????????????(100??????00100) if(101-j<=a_size){ a[101-j] = as[j-a_size] - '0'; }else{ a[101-j] = 0; } if(101-j<=b_size){ b[101-j] = bs[j-a_size] - '0'; }else{ b[101-j] = 0; } } for(j=0;j<102;j++){ //sum????¨???? sum[j] = a[j] + b[j]; if(flag){ //??°????????? sum[j] += 1; flag = 0; } if(j>=80&&sum[j]!=0){ //??????????????????????????? overflow = 1; break; } if(sum[j] > 9){ //??°??????????????? sum[j] -= 10; flag = 1; } } if(overflow){ //?????? std::cout << "overflow" << std::endl; overflow = 0; continue; } for(j=0;j<102;j++){ if(sum[101-j]!=0){ sum_size = 101-j; break; } } for(j=sum_size;j>=0;j--){ num = sum[j] + '0'; std::cout << num; } std::cout << std::endl; } }
a.cc: In function 'int main()': a.cc:40:9: error: 'overflow' was not declared in this scope 40 | overflow = 1; | ^~~~~~~~ a.cc:48:8: error: 'overflow' was not declared in this scope 48 | if(overflow){ //?????? | ^~~~~~~~
s464441474
p00015
C++
#include<iostream> #include<string> char iota(int n){ switch (n) { case 0: return '0'; case 1: return '1'; case 2: return '2'; case 3: return '3'; case 4: return '4'; case 5: return '5'; case 6: return '6'; case 7: return '7'; case 8: return '8'; case 9: return '9'; } return '0'; } int main(){ std::string num1; //("10000"); std::string num2: //("990000"); char sum[100]={}; int n,i,j,flag=0,temp; std::cin >> n; //n=1; for(i=0;i<100;i++){ sum[i]='\0'; } for(i=0;i<n;i++){ std::cin >> num1 >> num2; if(num1.size()<num2.size()){ num1.swap(num2); } //std::cout << num1 << std::endl; //std::cout << num2 << std::endl; for(j=0;j<num1.size();j++){ if(j<num2.size()){ temp = (num1[num1.size()-j-1]-'0')+(num2[num2.size()-j-1]-'0'); } if(j>=num2.size()){ temp = num1[num1.size()-j-1]-'0'; } if(flag){ ++temp; flag = 0; } if(temp>9){ temp -= 10; flag = 1; } sum[j] = iota(temp); } if(flag){ sum[j] = '1'; flag = 0; } //printf("%s\n",sum); j=0; while(sum[j]!='\0'){ ++j; } if(j>80){ std::cout << "overflow" << std::endl; }else{ while(j>0){ std::cout << sum[j-1]; --j; } std::cout << std::endl; } } }
a.cc: In function 'int main()': a.cc:23:19: error: expected initializer before ':' token 23 | std::string num2: //("990000"); | ^ a.cc:30:5: error: 'sum' was not declared in this scope 30 | sum[i]='\0'; | ^~~ a.cc:34:25: error: 'num2' was not declared in this scope; did you mean 'num1'? 34 | std::cin >> num1 >> num2; | ^~~~ | num1 a.cc:55:7: error: 'sum' was not declared in this scope 55 | sum[j] = iota(temp); | ^~~ a.cc:58:7: error: 'sum' was not declared in this scope 58 | sum[j] = '1'; | ^~~ a.cc:63:11: error: 'sum' was not declared in this scope 63 | while(sum[j]!='\0'){ | ^~~ a.cc:70:22: error: 'sum' was not declared in this scope 70 | std::cout << sum[j-1]; | ^~~
s530567436
p00015
C++
#include <assert.h> #include <stdio.h> #include <stdlib.h> #include <string.h> // typedef std::vector<char> TLongInt; // TLongInt Decode(const std::string& Code) // { // std::vector<char> Value(100, 0); // for(int i = 0; i < Code.size(); ++i){ // Value[i] = Code[Code.size() -1 -i] - '0'; // } // return Value; // } // TLongInt Add(const TLongInt& A, const TLongInt& B) // { // assert(A.size() == B.size()); // TLongInt C(A.size(), 0); // int kuriagari = 0; // for(int i = 0; i < A.size(); ++i){ // int V = A[i] + B[i] + kuriagari; // C[i] = V % 10; // kuriagari = V / 10; // } // return C; // } // void Print(const TLongInt& Value, std::ostream& out) // { // bool Left = true??? // for(int i = Value.size() - 1; i >= 0; --i){ // if(Value[i] == 0 && Left) continue; // if(i >= 80){ // out << "overflow" << std::endl; // return; // } // Left = false; // out << int(Value[i]); // } // if(Left) out << "0"; // out << std::endl; // } char* add(const char* a, const char* b) { int sizeA, sizeB, sizeX; int A, B, C; char* x; char* t; const char* ap; const char* bp; char* xp; C = 0; sizeA = strlen(a); sizeB = strlen(b); sizeX = (sizeA > sizeB ? sizeA : sizeB)+1; x = malloc(sizeX); ap = a + sizeA-1; bp = b + sizeB-1; xp = x + sizeX-1; while(xp >= x){ A = ap < a ? 0 : *ap - '0'; B = bp < b ? 0 : *bp - '0'; *xp = '0' + (A + B + C) % 10; C = (A + B + C) / 10; ap--; bp--; xp--; } if (*x == '0'){ t = malloc(sizeX - 1); strcpy(t, x + 1); free(x); return t; } return x; } int main() { int N; scanf("%d", &N); for(int i = 0; i < N; ++i){ char first[101]; char second[101]; scanf("%s", first); scanf("%s", second); if(strlen(first) > 80 || strlen(second) > 80){ printf("overflow\n"); continue; } char* result = add(first, second); if(strlen(result) <= 80){ printf("%s\n", result); free(result); }else{ printf("overflow\n"); } } return 0; }
a.cc: In function 'char* add(const char*, const char*)': a.cc:57:15: error: invalid conversion from 'void*' to 'char*' [-fpermissive] 57 | x = malloc(sizeX); | ~~~~~~^~~~~~~ | | | void* a.cc:72:19: error: invalid conversion from 'void*' to 'char*' [-fpermissive] 72 | t = malloc(sizeX - 1); | ~~~~~~^~~~~~~~~~~ | | | void*
s627474768
p00015
C++
#include<iostream> #include<string> using namespace std; int main(){ int n,k=0; for(cin>>n;n--;){ string a,b; cin >> a; cin >> b; if(a.size < b.size()) swap(a,b);//????????????a>b????????? while(b.size() < a.size()) b += '0';//????????????a==b????????? for(int i=a.size()-1;i>=0;i--){//??????????????????????????? a[i] += b[i] + k; if(a[i] > '9'){ a[i]-=10; k = 1; } else k = 0; } if(k) a+="1";//??°??????????????????????????????????¶?????????¨??? if(a.size() > 80) cout << "overflow" << endl; else cout << a << endl; } return 0; }
a.cc: In function 'int main()': a.cc:10:14: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?) 10 | if(a.size < b.size()) swap(a,b);//????????????a>b????????? | ~~^~~~ | ()
s044171280
p00015
C++
#include<iostream> #include<string> using namespace std; ios::sync_with_stdio(false); int main(){ int n; for(cin>>n;n--;){ int k=0; string a,b; cin >> a; cin >> b; if(a.size() < b.size()) swap(a,b);//????????????a>b????????? while(b.size() < a.size()) b = '0' + b;//????????????a==b????????? for(int i=a.size()-1;i>=0;i--){//??????????????????????????? a[i] += b[i] - '0' + k; if(a[i] > '9'){ a[i]-=10; k = 1; } else k = 0; } if(k) a="1"+a;//??°??????????????????????????????????¶?????????¨??? if(a.size() > 80) cout << "overflow" << "\n"; else cout << a << "\n"; } return 0; }
a.cc:4:1: error: specializing member 'std::basic_ios<char>::sync_with_stdio' requires 'template<>' syntax 4 | ios::sync_with_stdio(false); | ^~~
s532439119
p00015
C++
#include <stdio.h> #include <string.h> int max(int a, int b) { return a > b ? a : b; } int main(void) { int i, ans = 0, j, n; char a[110], b[110]; scanf("%d", &n); for(i = 0; i < n; ++i) { scanf("%s\n%s", a, b); if(strlen(a) > 80 || strlen(b) > 80) { printf("overflow\n"); continue; } for(j = 0; j < strlen(a); ++j) a[j] -= '0' - 1; for(j = 0; j < strlen(b); ++j) b[j] -= '0' - 1; /*for(j = 0; j < strlen(a); ++j) printf("%d", (int)a[j] - 1); printf("\n"); for(j = 0; j < strlen(b); ++j) printf("%d", (int)b[j] - 1); printf("\n");*/ if(strlen(a) < strlen(b)) { char t[110]; for(j = 0; j <= strlen(a); ++j) t[j] = a[j]; for(j = 0; j <= strlen(b); ++j) a[j] = b[j]; for(j = 0; j <= strlen(t); ++j) b[j] = t[j]; } char t[110]; int st = 0; for(j = 0; j <= strlen(b); ++j) t[j] = b[j]; for(j = 0; j <= strlen(a); ++j) b[j] = 1; for(j = strlen(a) - strlen(t); j <= strlen(a); ++j) b[j] = t[j - strlen(a) + strlen(t)]; /*for(j = 0; j < strlen(a); ++j) printf("%d", (int)a[j] - 1); printf("\n"); for(j = 0; j < strlen(a); ++j) printf("%d", (int)b[j] - 1); printf("\n");*/ for(j = strlen(a) - 1; j >= 0; --j) { a[j] = a[j] + b[j] - 1; if(a[j] >= 11) { if(j) { a[j - 1]++; a[j] -= 10; } else { st = 1; a[j] -= 10; } } } if(st) { if(strlen(a) == 80) { printf("overflow\n"); continue; } else printf("1"); } for(j = 0; j < strlen(a); ++j) printf("%d", (int)a[j] - 1); printf("\n"); } return 0; } Compile Error Logs: Status Judge: 1/1 C++ CPU: 00:00 sec Memory: 2596 KB Length: 1647 B 2018-03-03 23:04 Results for testcases Case # Verdict CPU Time Memory In Out Case Name Case #1 : Accepted 00:00 2596 0 0 judge_data < prev | / | next > Judge Input # ( | ) Judge Output # ( | )
a.cc:68:6: error: stray '#' in program 68 | Case # Verdict CPU Time Memory In Out Case Name | ^ a.cc:69:6: error: stray '#' in program 69 | Case #1 : Accepted 00:00 2596 0 0 judge_data | ^ a.cc:73:13: error: stray '#' in program 73 | Judge Input # ( | ) Judge Output # ( | ) | ^ a.cc:73:46: error: stray '#' in program 73 | Judge Input # ( | ) Judge Output # ( | ) | ^ a.cc:63:1: error: 'Compile' does not name a type 63 | Compile Error Logs: | ^~~~~~~
s464657696
p00015
C++
#include <iostream> #include <vector> #include <string> using namespace std; typedef vector <int> VI; VI string_to_vi( string number ) { VI converted( number.size() ); for ( int i = 0; i < number.size(); i++ ) converted[i] = (int)( number[i] - '0' ); return converted; } VI add( VI left, VI right ) { VI result; reverse( left.begin(), left.end() ); reverse( right.begin(), right.end() ); VI::iterator it_left = left.begin(); VI::iterator it_right = right.begin(); int carry = 0; while ( it_left != left.end() || it_right != right.end() ) { int l = 0, r = 0; if ( it_left != left.end() ) l = *it_left; if ( it_right != right.end() ) r = *it_right; result.push_back( ( l + r + carry ) % 10 ); carry = ( l + r + carry >= 10 ) ? 1 : 0; if ( it_left != left.end() ) it_left ++; if ( it_right != right.end() ) it_right ++; } if ( carry ) result.push_back( 1 ); reverse( result.begin(), result.end() ); return result; } int main( void ) { int n; cin >> n; for ( int i = 0; i < n; i++ ) { string input_a, input_b; cin >> input_a >> input_b; VI a = string_to_vi( input_a ); VI b = string_to_vi( input_b ); VI c = add( a, b ); for ( VI::iterator it = c.begin(); it != c.end(); it++ ) cout << *it; cout << endl; } return 0; }
a.cc: In function 'VI add(VI, VI)': a.cc:17:9: error: 'reverse' was not declared in this scope 17 | reverse( left.begin(), left.end() ); | ^~~~~~~
s426130263
p00015
C++
import java.util.Scanner; import java.math.BigInteger; public class Main{ public static void main(String args[]) { Scanner scanner = new Scanner(System.in); int N = scanner.nextInt(); for (int i = 0; i < N; i++) { String a = scanner.nextString(), b = scanner.nextString(); BigInteger sum = BigInteger(a) + BigInteger(b); String n_80 = "1"; for (int j = 0; j < 79; j++) { n_80 += "0"; } if (sum >= BigInteger(n_80)) { System.out.println("overflow"); } else { System.out.println(sum.toString()); } } } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.util.Scanner; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import java.math.BigInteger; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: expected unqualified-id before 'public' 4 | public class Main{ | ^~~~~~
s451204457
p00015
C++
import java.util.Scanner; import java.math.BigInteger; public class Main{ public static void main(String args[]) { Scanner scanner = new Scanner(System.in); int N = scanner.nextInt(); for (int i = 0; i < N; i++) { String a = scanner.next(), b = scanner.next(); BigInteger sum = new BigInteger(a), A = new BigInteger(b); sum.add(A); String n_80 = "1"; for (int j = 0; j < 79; j++) { n_80 += "0"; } BigInteger N_80 = new BigInteger(n_80); if (sum.compareTo(N_80) >= 0) { System.out.println("overflow"); } else { System.out.println(sum.toString()); } } } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.util.Scanner; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import java.math.BigInteger; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: expected unqualified-id before 'public' 4 | public class Main{ | ^~~~~~
s589558237
p00015
C++
#include<iostream> #include<algorithm> #include<vector> #include<stack> #include<queue> #include<cstdio> #include<climits> #include<cmath> #include<cstring> #include<string> #include<complex> #include<cfloat> #define f first #define s second #define mp make_pair #define REP(i,n) for(int i=0; i<(int)(n); i++) #define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++) #define ALL(c) (c).begin(), (c).end() #define EPS (1e-10) using namespace std; typedef unsigned int uint; typedef long long ll; typedef complex<double> P; #define PI (3.1415926535) #define EPS (1e-10) class BigInteger{ private: void fromStr(const std::string &str){ int len = str.size(); int tmp = 0; if(str[0] == '+'){ sign = 1; tmp=1; }else if (str[0] == '-'){ sign = -1; tmp=1; }else{ sign = 1; } nums = std::vector<char>(len-tmp); for(int i=0;i<len-tmp;i++){ nums[i]=str[len-1-i]-'0'; } } public: std::vector<char> nums; char sign; /* * constructors */ BigInteger(){sign = 1;nums = std::vector<char>(1,0);} BigInteger(const std::vector<char> n,char s){ nums = n; assert(s == 1 || s == -1); sign = s; } BigInteger(const std::string &str){ fromStr(str); } BigInteger(int n){ char buff[16]; sprintf(buff,"%d",n); fromStr(std::string(buff)); } int size() const{ return nums.size(); } int len() const{ return nums.size(); } char operator [] (int n) const{ if(n<size() && n>=0) return nums[n]; else return 0; } const std::vector<char> &vec() const{ return nums; } char sig() const{ return sign; } std::string toString() const{ std::string ret=""; if(sign == -1) ret+="-"; for(int i=nums.size()-1;i>=0;i--){ ret+=nums[i]+'0'; } return ret; } void debug() const{ std::cout << "sign =" << (int)sign << std::endl; for(int i=nums.size()-1;i>=0;i--){ std::cout << (int)nums[i] << " "; } std::cout << std::endl; } }; std::ostream &operator << (std::ostream &s , const BigInteger &i){ return s << i.toString(); } bool operator > (const BigInteger &a,const BigInteger &b){ char as = a.sig(); char bs = b.sig(); if(as == 1 && bs ==1){ if(a.len() == b.len()){ int i=a.len(); while(--i != -1){ if(a[i] != b[i]){ return a[i] > b[i]; } } return false; }else{ return a.len() > b.len(); } }else if(as == -1 && bs == -1){ if(a.len() == b.len()){ int i=a.len(); while(--i != 0){ if(a[i] != b[i]){ return a[i] < b[i]; } } return false; }else{ return a.len() < b.len(); } }else{ return as == 1; } } bool operator < (const BigInteger &a,const BigInteger &b){ return b > a; } bool operator == (const BigInteger &a,const BigInteger &b){ char as = a.sig(); char bs = b.sig(); if(as != bs) return false; if(a.len() != b.len()){ return false; }else{ for(int i=0;i<a.len();i++){ if(a[i]!=b[i]) return false; } } return true; } bool operator != (const BigInteger &a,const BigInteger &b){ return !(a==b); } /* operator */ BigInteger operator - (const BigInteger &a){ return BigInteger(a.vec(),-a.sig()); } BigInteger operator + (const BigInteger &a,const BigInteger &b){ int lena = a.size(); int lenb = b.size(); int maxlen = std::max(lena,lenb); std::vector<char> v = std::vector<char>(maxlen+1,0); int sig = 1; for(int i=0;i<maxlen;i++){ v[i] += a.sig()*a[i]+b.sig()*b[i]; while(v[i] < 0){ v[i+1]--; v[i]+=10; std::cout << "test" << std::endl; } if(v[i] >=10){ v[i+1] = v[i]/10; v[i]%=10; } } if(v[maxlen]<0){ sig = -1; for(int i=0;i<maxlen;i++){ v[i]=-v[i]; while(v[i]<0){ v[i+1]++; v[i]+=10; } } v[maxlen]=-v[maxlen]; } int pos=v.size(); while(pos!=1 && v[pos-1]==0) pos--; if(pos != v.size()) v.resize(pos); return BigInteger(v,sig); } BigInteger operator + (const BigInteger &a,int b){ return a+BigInteger(b); } BigInteger &operator += (BigInteger &a,const BigInteger &b){ a = a+b; return a; } BigInteger &operator += (BigInteger &a,int b){ a = a+b; return a; } BigInteger &operator ++ (BigInteger &a){ a = a + BigInteger(1); return a; } BigInteger operator - (const BigInteger &a,const BigInteger &b){ return a + (- b); } BigInteger operator * (const BigInteger &a,const BigInteger &b){ int len = a.size() + b.size() + 2; int sign = a.sig()*b.sig(); std::vector<char> v(len); for(int i=0;i<a.size();i++){ if(a[i] == 0) continue; for(int j=0;j<b.size();j++){ v[i+j] += a[i]*b[j]; if(v[i+j] >=10){ v[i+j+1] = v[i+j]/10; v[i+j]%=10; } } } int pos=v.size(); while(pos!=1 && v[pos-1]==0) pos--; if(pos != v.size()) v.resize(pos); return BigInteger(v,sign); } BigInteger operator * (const BigInteger &a,int b){ return a*BigInteger(b); } BigInteger &operator *= (BigInteger &a,const BigInteger &b){ a = a*b; return a; } BigInteger &operator *= (BigInteger &a,int b){ a = a*b; return a; } BigInteger reverse(const BigInteger &a){ BigInteger b=a; std::reverse(b.nums.begin(),b.nums.end()); return b; } BigInteger power(BigInteger a,int b){ if(b == 0) return BigInteger(1); if((b&1) != 0){ return a*power(a*a,b>>1); }else{ return power(a*a,b>>1); } } int main(){ int n; cin>>n; while(n-->0){ string s1,s2; cin>>s1>>s2; BigInteger b1(s1), b2(s2); cout << b1+b2 << endl; } return 0; }
a.cc: In constructor 'BigInteger::BigInteger(std::vector<char>, char)': a.cc:60:5: error: 'assert' was not declared in this scope 60 | assert(s == 1 || s == -1); | ^~~~~~ a.cc:13:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>' 12 | #include<cfloat> +++ |+#include <cassert> 13 |