submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s555447598
p00009
C
#include <stdio.h> int main(void){ char check=1; int i,j,k,m,n; int num[150000]; num[0] = 2;    k=0 for(i=3;i<=1000000;i=i+2){ for( j=0; j<=k; j++){ if(i%num[j] == 0){ check =0; break; } if(!check ) break; } if(check){        K++; num[k]=i; }else check =1; }    while( (scanf("%d",&n);) != EOF){ for(m=0; m<=k; m++){ if( num[m]<=n) break; } printf("%d\n",m+1); } return 0; }
main.c: In function 'main': main.c:9:1: error: stray '\343' in program 9 | <U+3000><U+3000><U+3000>k=0 | ^~~~~~~~ main.c:9:3: error: stray '\343' in program 9 | <U+3000><U+3000><U+3000>k=0 | ^~~~~~~~ main.c:9:5: error: stray '\343' in program 9 | <U+3000><U+3000><U+3000>k=0 | ^~~~~~~~ main.c:9:10: error: expected ';' before 'for' 9 |    k=0 | ^ | ; 10 | for(i=3;i<=1000000;i=i+2){ | ~~~ main.c:19:1: error: stray '\343' in program 19 | <U+3000><U+3000><U+3000><U+3000><U+3000><U+3000><U+3000>K++; | ^~~~~~~~ main.c:19:3: error: stray '\343' in program 19 | <U+3000><U+3000><U+3000><U+3000><U+3000><U+3000><U+3000>K++; | ^~~~~~~~ main.c:19:5: error: stray '\343' in program 19 | <U+3000><U+3000><U+3000><U+3000><U+3000><U+3000><U+3000>K++; | ^~~~~~~~ main.c:19:7: error: stray '\343' in program 19 | <U+3000><U+3000><U+3000><U+3000><U+3000><U+3000><U+3000>K++; | ^~~~~~~~ main.c:19:9: error: stray '\343' in program 19 | <U+3000><U+3000><U+3000><U+3000><U+3000><U+3000><U+3000>K++; | ^~~~~~~~ main.c:19:11: error: stray '\343' in program 19 | <U+3000><U+3000><U+3000><U+3000><U+3000><U+3000><U+3000>K++; | ^~~~~~~~ main.c:19:13: error: stray '\343' in program 19 | <U+3000><U+3000><U+3000><U+3000><U+3000><U+3000><U+3000>K++; | ^~~~~~~~ main.c: At top level: main.c:26:1: error: stray '\343' in program 26 | <U+3000><U+3000> while( (scanf("%d",&n);) != EOF){ | ^~~~~~~~ main.c:26:3: error: stray '\343' in program 26 | <U+3000><U+3000> while( (scanf("%d",&n);) != EOF){ | ^~~~~~~~ main.c:26:7: error: expected identifier or '(' before 'while' 26 |    while( (scanf("%d",&n);) != EOF){ | ^~~~~ main.c:26:30: error: expected identifier or '(' before ')' token 26 |    while( (scanf("%d",&n);) != EOF){ | ^ main.c:33:8: error: expected identifier or '(' before 'return' 33 | return 0; | ^~~~~~ main.c:34:1: error: expected identifier or '(' before '}' token 34 | } | ^
s139388901
p00009
C
#include <stdio.h> int main(void){ char check=1; int i,j,k,m,n; int num[150000]; num[0] = 2;    k=0; for(i=3;i<=1000000;i=i+2){ for( j=0; j<=k; j++){ if(i%num[j] == 0){ check =0; break; } if(!check ) break; } if(check){        K++; num[k]=i; }else check =1; }    while( (scanf("%d",&n);) != EOF){ for(m=0; m<=k; m++){ if( num[m]<=n) break; } printf("%d\n",m+1); } return 0; }
main.c: In function 'main': main.c:9:1: error: stray '\343' in program 9 | <U+3000><U+3000><U+3000>k=0; | ^~~~~~~~ main.c:9:3: error: stray '\343' in program 9 | <U+3000><U+3000><U+3000>k=0; | ^~~~~~~~ main.c:9:5: error: stray '\343' in program 9 | <U+3000><U+3000><U+3000>k=0; | ^~~~~~~~ main.c:19:1: error: stray '\343' in program 19 | <U+3000><U+3000><U+3000><U+3000><U+3000><U+3000><U+3000>K++; | ^~~~~~~~ main.c:19:3: error: stray '\343' in program 19 | <U+3000><U+3000><U+3000><U+3000><U+3000><U+3000><U+3000>K++; | ^~~~~~~~ main.c:19:5: error: stray '\343' in program 19 | <U+3000><U+3000><U+3000><U+3000><U+3000><U+3000><U+3000>K++; | ^~~~~~~~ main.c:19:7: error: stray '\343' in program 19 | <U+3000><U+3000><U+3000><U+3000><U+3000><U+3000><U+3000>K++; | ^~~~~~~~ main.c:19:9: error: stray '\343' in program 19 | <U+3000><U+3000><U+3000><U+3000><U+3000><U+3000><U+3000>K++; | ^~~~~~~~ main.c:19:11: error: stray '\343' in program 19 | <U+3000><U+3000><U+3000><U+3000><U+3000><U+3000><U+3000>K++; | ^~~~~~~~ main.c:19:13: error: stray '\343' in program 19 | <U+3000><U+3000><U+3000><U+3000><U+3000><U+3000><U+3000>K++; | ^~~~~~~~ main.c:18:21: error: '\U0000ff5b' undeclared (first use in this function) 18 | if(check){ | ^~ main.c:18:21: note: each undeclared identifier is reported only once for each function it appears in main.c:18:23: error: expected ';' before 'K' 18 | if(check){ | ^ | ; 19 |        K++; | ~ main.c:21:12: error: 'else' without a previous 'if' 21 | }else | ^~~~ main.c: At top level: main.c:26:1: error: stray '\343' in program 26 | <U+3000><U+3000> while( (scanf("%d",&n);) != EOF){ | ^~~~~~~~ main.c:26:3: error: stray '\343' in program 26 | <U+3000><U+3000> while( (scanf("%d",&n);) != EOF){ | ^~~~~~~~ main.c:26:7: error: expected identifier or '(' before 'while' 26 |    while( (scanf("%d",&n);) != EOF){ | ^~~~~ main.c:26:30: error: expected identifier or '(' before ')' token 26 |    while( (scanf("%d",&n);) != EOF){ | ^ main.c:33:8: error: expected identifier or '(' before 'return' 33 | return 0; | ^~~~~~ main.c:34:1: error: expected identifier or '(' before '}' token 34 | } | ^
s761690500
p00009
C
#include <stdio.h> int main(void){ char check=1; int i,j,k,m,n; int num[150000]; num[0] = 2; k=0; for(i=3;i<=1000000;i=i+2){ for( j=0; j<=k; j++){ if(i%num[j] == 0){ check =0; break; } if(!check ) break; } if(check){        k++; num[k]=i; }else check =1; }    while( (scanf("%d",&n);) != EOF){ for(m=0; m<=k; m++){ if( num[m]<=n) break; } printf("%d\n",m+1); } return 0; }
main.c: In function 'main': main.c:19:1: error: stray '\343' in program 19 | <U+3000><U+3000><U+3000><U+3000><U+3000><U+3000><U+3000>k++; | ^~~~~~~~ main.c:19:3: error: stray '\343' in program 19 | <U+3000><U+3000><U+3000><U+3000><U+3000><U+3000><U+3000>k++; | ^~~~~~~~ main.c:19:5: error: stray '\343' in program 19 | <U+3000><U+3000><U+3000><U+3000><U+3000><U+3000><U+3000>k++; | ^~~~~~~~ main.c:19:7: error: stray '\343' in program 19 | <U+3000><U+3000><U+3000><U+3000><U+3000><U+3000><U+3000>k++; | ^~~~~~~~ main.c:19:9: error: stray '\343' in program 19 | <U+3000><U+3000><U+3000><U+3000><U+3000><U+3000><U+3000>k++; | ^~~~~~~~ main.c:19:11: error: stray '\343' in program 19 | <U+3000><U+3000><U+3000><U+3000><U+3000><U+3000><U+3000>k++; | ^~~~~~~~ main.c:19:13: error: stray '\343' in program 19 | <U+3000><U+3000><U+3000><U+3000><U+3000><U+3000><U+3000>k++; | ^~~~~~~~ main.c:18:21: error: '\U0000ff5b' undeclared (first use in this function) 18 | if(check){ | ^~ main.c:18:21: note: each undeclared identifier is reported only once for each function it appears in main.c:18:23: error: expected ';' before 'k' 18 | if(check){ | ^ | ; 19 |        k++; | ~ main.c:21:12: error: 'else' without a previous 'if' 21 | }else | ^~~~ main.c: At top level: main.c:26:1: error: stray '\343' in program 26 | <U+3000><U+3000> while( (scanf("%d",&n);) != EOF){ | ^~~~~~~~ main.c:26:3: error: stray '\343' in program 26 | <U+3000><U+3000> while( (scanf("%d",&n);) != EOF){ | ^~~~~~~~ main.c:26:7: error: expected identifier or '(' before 'while' 26 |    while( (scanf("%d",&n);) != EOF){ | ^~~~~ main.c:26:30: error: expected identifier or '(' before ')' token 26 |    while( (scanf("%d",&n);) != EOF){ | ^ main.c:33:8: error: expected identifier or '(' before 'return' 33 | return 0; | ^~~~~~ main.c:34:1: error: expected identifier or '(' before '}' token 34 | } | ^
s612859285
p00009
C
#include <stdio.h> int main(void){ char check=1; int i,j,k,m,n; int num[150000]; num[0] = 2; k=0; for(i=3;i<=1000000;i=i+2){ for( j=0; j<=k; j++){ if(i%num[j] == 0){ check =0; break; } if(!check ) break; } if(check){        k++; num[k]=i; }else{ check =1; } }    while( scanf("%d",&n) != EOF){ for(m=0; m<=k; m++){ if( num[m]<=n) break; } printf("%d\n",m+1); } return 0; }
main.c: In function 'main': main.c:19:1: error: stray '\343' in program 19 | <U+3000><U+3000><U+3000><U+3000><U+3000><U+3000><U+3000>k++; | ^~~~~~~~ main.c:19:3: error: stray '\343' in program 19 | <U+3000><U+3000><U+3000><U+3000><U+3000><U+3000><U+3000>k++; | ^~~~~~~~ main.c:19:5: error: stray '\343' in program 19 | <U+3000><U+3000><U+3000><U+3000><U+3000><U+3000><U+3000>k++; | ^~~~~~~~ main.c:19:7: error: stray '\343' in program 19 | <U+3000><U+3000><U+3000><U+3000><U+3000><U+3000><U+3000>k++; | ^~~~~~~~ main.c:19:9: error: stray '\343' in program 19 | <U+3000><U+3000><U+3000><U+3000><U+3000><U+3000><U+3000>k++; | ^~~~~~~~ main.c:19:11: error: stray '\343' in program 19 | <U+3000><U+3000><U+3000><U+3000><U+3000><U+3000><U+3000>k++; | ^~~~~~~~ main.c:19:13: error: stray '\343' in program 19 | <U+3000><U+3000><U+3000><U+3000><U+3000><U+3000><U+3000>k++; | ^~~~~~~~ main.c:27:1: error: stray '\343' in program 27 | <U+3000><U+3000> while( scanf("%d",&n) != EOF){ | ^~~~~~~~ main.c:27:3: error: stray '\343' in program 27 | <U+3000><U+3000> while( scanf("%d",&n) != EOF){ | ^~~~~~~~
s103279602
p00009
C
#include <stdio.h> int main(void){ char check=1; int i,j,k,m,n; int num[150000]; num[0] = 2; k=0; for(i=3;i<=1000000;i=i+2){ for( j=0; j<=k; j++){ if(i%num[j] == 0){ check =0; break; } if(!check ) break; } if(check){ k++; num[k]=i; }else{ check =1; } }    while( scanf("%d",&n) != EOF){ for(m=0; m<=k; m++){ if( num[m]<=n) break; } printf("%d\n",m+1); } return 0; }
main.c: In function 'main': main.c:25:1: error: stray '\343' in program 25 | <U+3000><U+3000> while( scanf("%d",&n) != EOF){ | ^~~~~~~~ main.c:25:3: error: stray '\343' in program 25 | <U+3000><U+3000> while( scanf("%d",&n) != EOF){ | ^~~~~~~~
s343609520
p00009
C
#include <stdio.h> int main(void){ int n; int prime[270000]; prime[0]=2; int i,j,k=1,num,check; for( i=3; i<1000000;i=i+2){ check =1; for(j=0;j<k; j++){ if(a%prime[j] == 0 ){ check =0; break; } if(check){ prime[k] =i; k++; } } while( scanf("%d",&n) != EOF){ for(i=0; i<=k; i++){ if( prime[i] < n){ printf("%d",i+1); } return 0; }
main.c: In function 'main': main.c:11:18: error: 'a' undeclared (first use in this function) 11 | if(a%prime[j] == 0 ){ | ^ main.c:11:18: note: each undeclared identifier is reported only once for each function it appears in main.c:24:1: error: expected declaration or statement at end of input 24 | } | ^ main.c:24:1: error: expected declaration or statement at end of input main.c:24:1: error: expected declaration or statement at end of input
s186106395
p00009
C
#include <stdio.h> int main(void){ int n; int prime[270000]; prime[0]=2; int i,j,k=1,num,check; for( i=3; i<1000000;i=i+2){ check =1; for(j=0;j<k; j++){ if(i%prime[j] == 0 ){ check =0; break; } if(check){ prime[k] =i; k++; } } while( scanf("%d",&n) != EOF){ for(i=0; i<=k; i++){ if( prime[i] < n) printf("%d",i+1); } } return 0; }
main.c: In function 'main': main.c:25:1: error: expected declaration or statement at end of input 25 | } | ^
s726272452
p00009
C
#include <stdio.h> int prime_check(int a){ int prime[270000]; prime[0]=2; prime[1]=3; int i,j,k=0; int check; if( a ==1) return 0; for(i=1;<=166667;i++){ check =1; for(j=0;j<=k;j++){ if((6*i+1)% prime[j] == 0) check =0; } if(check){ k++; prime[k]=i; } check =1; for(j=0;j<=k;j++){ if((6*i+5)% prime[j] == 0) check =0; } if(check){ k++; prime[k]=i; } } for(j=0;j<=k;j++) { if(a<prime[j] ) return j; } } int main(void){ int N,prime; while(scanf("%d",&N) != EOF) { printf("%d\n",prime_check(N)); } return 0; }
main.c: In function 'prime_check': main.c:11:17: error: expected expression before '<=' token 11 | for(i=1;<=166667;i++){ | ^~
s191656852
p00009
C
#include <stdio.h> int check(unsigned long num) { unsigned long i; if(num == 1){ return 0; } if(num == 2){ return 1; } if(num == 3){ return 1; } if(num == 4){ return 0; } for(i=2; i<(num/2); i++){ if((num%i) == 0){ return 0; } } return 1; } int main() { unsigned long n, i, j, buf, cnt; bool flag=1; while(flag == 1){ cnt = 0; //printf("Please input any number :"); scanf("%lu", &n); getchar(); if(n == 0){ //printf("result :0\n"); printf("0\n"); }else{ for(i=1; i<=n; i++){ cnt += check(i); //printf("%10lu: %lu\n", i, cnt); } } //printf("result :%lu\n\n", cnt); printf("%lu\n", cnt); } }
main.c: In function 'main': main.c:24:9: error: unknown type name 'bool' 24 | bool flag=1; | ^~~~ main.c:2:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' 1 | #include <stdio.h> +++ |+#include <stdbool.h> 2 |
s115611517
p00009
C
#include<iostream> using namespace std; int F(int n) { int result=0; if (n==1 || n==0) result=0; else { for(int i=2;i<=n;i++) { int flag=0; for(int j=2;j<i;j++) { if(i%j==0) flag=1; } if(flag==0) result++; } } return result; } int main() { int number=0; while(1) { scanf("%d",&number); printf("%d\n",F(number)); } return 0; }
main.c:1:9: fatal error: iostream: No such file or directory 1 | #include<iostream> | ^~~~~~~~~~ compilation terminated.
s281056066
p00009
C
#include<conio.h> #include<stdio.h> int F(int n) { int result=0; if (n==1 || n==0) result=0; else { for(int i=2;i<=n;i++) { int flag=0; for(int j=2;j<i;j++) { if(i%j==0) flag=1; } if(flag==0) result++; } } return result; } int main() { int number=0; while(1) { scanf("%d",&number); printf("%d\n",F(number)); } return 0; }
main.c:1:9: fatal error: conio.h: No such file or directory 1 | #include<conio.h> | ^~~~~~~~~ compilation terminated.
s236956032
p00009
C
#include<stdio.h> #include<math.h> #define max 1000000 int main() { int a; int x,y,z; int r[max]; for(x=3;x<=max;x+=2){ r[x]=1; } while((scanf("%d",&a))!=EOF){ if(a==1){ printf("%d",1); continue; } y=sqrt((double)a); for(z=3;z<=y;z+=2) if(r[x]==1){ for(x=3;x<=a/z;x+=2){ r[x*z]=0; } } for(x=3;x<=a;x+=2){ if(r[x]==1) t++; } printf("%d\n",t); } return 0; }
main.c: In function 'main': main.c:30:33: error: 't' undeclared (first use in this function) 30 | t++; | ^ main.c:30:33: note: each undeclared identifier is reported only once for each function it appears in
s121668858
p00009
C
#include <stdio.h> #define N 100000 #define rep(i,n) for(int i=0;i<n;i++) int main(void) { bool a[N+1]; int prime[N], n; rep(i,N) { a[i] = true; } a[0] = a[1] = false; for(int i=2;i*i<=N;i++) { if(a[i]) { prime[i] = prime[i-1] + 1; for(int j=i*i;j<N;j+=i) a[j] = false; } else prime[i] = prime[i-1]; } while(scanf("%d", &n)!=EOF) printf("%d\n", prime[n]); return 0; }
main.c: In function 'main': main.c:7:5: error: unknown type name 'bool' 7 | bool a[N+1]; | ^~~~ main.c:2:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' 1 | #include <stdio.h> +++ |+#include <stdbool.h> 2 | #define N 100000 main.c:11:16: error: 'true' undeclared (first use in this function) 11 | a[i] = true; | ^~~~ main.c:11:16: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' main.c:11:16: note: each undeclared identifier is reported only once for each function it appears in main.c:13:19: error: 'false' undeclared (first use in this function) 13 | a[0] = a[1] = false; | ^~~~~ main.c:13:19: note: 'false' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
s382945600
p00009
C
#include <stdio.h> int main(void) { int a; while(scanf("%d", &a) != EOF) { printf("%d\n", prime(a)); } } int prime(int n) { int i, j, count = 0; for(i = 2;i <= n;i++) { for(j = 2;j*j <= i;j++) { if(i%j == 0) break; } if(j*j > i) count++; } return count; } return count; }
main.c: In function 'main': main.c:5:20: error: implicit declaration of function 'prime' [-Wimplicit-function-declaration] 5 | printf("%d\n", prime(a)); | ^~~~~ main.c: At top level: main.c:20:1: error: expected identifier or '(' before 'return' 20 | return count; | ^~~~~~ main.c:21:1: error: expected identifier or '(' before '}' token 21 | } | ^
s311686021
p00009
C
#include <stdio.h> int main(){ int n,i,j,a,f; int a[1000000]; for(i=2;i<1000000;i++){ a[i]=1; } for(i=2;i<1000000;i++){ for(j=2;j<i;j++){ a=i%j; if(a==0){ a[i]=0; break; } } } a[2]=1; while(scanf("%d",&n) != EOF){ f=0; for(i=2;i<=n;i++){ f+=a[i]; } printf("%d\n",f) } return 0; }
main.c: In function 'main': main.c:5:5: error: conflicting types for 'a'; have 'int[1000000]' 5 | int a[1000000]; | ^ main.c:4:11: note: previous declaration of 'a' with type 'int' 4 | int n,i,j,a,f; | ^ main.c:24:17: error: expected ';' before '}' token 24 | printf("%d\n",f) | ^ | ; 25 | 26 | } | ~
s909661595
p00009
C
#include<stdio.h> #include<cmath> #include<iostream> using namespace std; int a[1000010]; int main() { int fun(int n); int n,i,j,k,m; while(scanf("%d",&n)!=EOF) { memset(a,0,sizeof(a)); m=fun(n); printf("%d\n",m); } return 0; } int fun(int m) { int i,j,k=0,q; for(i=2;i<=m;i++) { for(j=2;i*j<=m;j++) { if(a[i*j]==0) { a[i*j]=-1; } } } for(i=2;i<=m;i++) if(a[i]==0)k++; return k; }
main.c:2:9: fatal error: cmath: No such file or directory 2 | #include<cmath> | ^~~~~~~ compilation terminated.
s824710411
p00009
C
#include <stdio.h> #include <math.h> int judgeprime(long num){ int primeflag=1,i; if(num%2==0){primeflag=0;} else for(i=3;i<sqrt(num);i+=2){ if( num%i==0 ){ primeflag=0; break; } } if(num==0||num==1||num==4){primeflag=0;} else if(num==2){primeflag=1;} return primeflag; } int main(void){ long i,num; int much; while( scanf("%ld",&num) != -1 ){ much=0; for(i=1;i<=num;i++){ much+=judgeprime(i); } printf("%d\n",much); } return 0; } 04:57:02 ~/programming/AOJ $
main.c:42:1: error: expected identifier or '(' before numeric constant 42 | 04:57:02 ~/programming/AOJ | ^~
s732131182
p00009
C
#include <stdio.h> #include <math.h> int main (void) { int n; int *list; while (scanf ("%d", &n) != EOF) { list = (int *) calloc (sizeof (int), n + 1); list[0] = list[1] = 0; for (int i = 2; i <= sqrt (n); i++) { if (list[i] == 0) { for (int j = i + 1; j <= n; j++) if (j % i == 0) list[j] = -1; } else continue; } for (int i = 2; i <= n; i++) if (list[i] == 0) list[0]++; printf ("%d\n", list[0]); free (list); } return 0; }
main.c: In function 'main': main.c:10:22: error: implicit declaration of function 'calloc' [-Wimplicit-function-declaration] 10 | list = (int *) calloc (sizeof (int), n + 1); | ^~~~~~ main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'calloc' 2 | #include <math.h> +++ |+#include <stdlib.h> 3 | int main.c:10:22: warning: incompatible implicit declaration of built-in function 'calloc' [-Wbuiltin-declaration-mismatch] 10 | list = (int *) calloc (sizeof (int), n + 1); | ^~~~~~ main.c:10:22: note: include '<stdlib.h>' or provide a declaration of 'calloc' main.c:27:7: error: implicit declaration of function 'free' [-Wimplicit-function-declaration] 27 | free (list); | ^~~~ main.c:27:7: note: include '<stdlib.h>' or provide a declaration of 'free' main.c:27:7: warning: incompatible implicit declaration of built-in function 'free' [-Wbuiltin-declaration-mismatch] main.c:27:7: note: include '<stdlib.h>' or provide a declaration of 'free'
s079011806
p00009
C
#include<stdio.h> #define N 1000000 int main(void) { int ans,n,i; int a,m,TBL[N]; float AM=10; // forの条件式をスルーするために10代入 for(a=3;a<N;a+=2) TBL[a]=0; for(a=3;a<N;a+=2){ if(TBL[a]==0){ TBL[a]==1; for(m=2;AM<N;m++){ AM=a*m; TBL[AM]=-1; } } } while(scanf("%d",&n)!=EOF){ ans=1; for(i=3;i<=n;i+=2){ if(TBL[i]==1) ans++; } printf("%d\n",ans); } return 0; }
main.c: In function 'main': main.c:14:36: error: array subscript is not an integer 14 | TBL[AM]=-1; | ^
s037626150
p00009
C
#include <stdio.h> #define NPRIMES 1000 #define FALSE 0 #define TRUE 1 int main(void) { int n; int i,j; int flag; int primes[NPRIMES]; int level; printf("Enter value of N > "); scanf("%d",&n); level = 0; for(i=2;i<=n;i++) { for(j = 0, flag = TRUE; j<level && flag; j++) flag = (i%primes[j]); if (flag) printf("%12d\n", i); if (level < NPRIMES) primes[level++] = i; } } }
main.c:29:1: error: expected identifier or '(' before '}' token 29 | } | ^
s680379864
p00009
C
#include<stdio.h> #define N 1000000 int main(void) { int ans,n,i; int a,m,TBL[N]; float AM=10; // forの条件式をスルーするために10代入 for(a=3;a<N;a+=2) TBL[a]=0; for(a=3;a<N;a+=2){ if(TBL[a]==0){ TBL[a]==1; for(m=2;AM<N;m++){ AM=a*m; TBL[AM]=-1; } } } while(scanf("%d",&n)!=EOF){ ans=1; for(i=3;i<=n;i+=2){ if(TBL[i]==1) ans++; } printf("%d\n",ans); } return 0; }
main.c: In function 'main': main.c:14:36: error: array subscript is not an integer 14 | TBL[AM]=-1; | ^
s571783543
p00009
C
#include<iostream> using namespace std; #define N 200000 int main() { int a[N]={0},n,i,j,z; for(i=2;i<=N/2;i++){ if(a[i]==0){ for(j=2;j*i<=N;j++){ a[i*j]=1; } } } while((cin>>n)!=0){ z=0; for(i=2;i<=n;i++){ if(a[i]==0)z++; } cout<<z<<endl; } return 0; }
main.c:1:9: fatal error: iostream: No such file or directory 1 | #include<iostream> | ^~~~~~~~~~ compilation terminated.
s053052926
p00009
C
int main(void){ int i,j,sq_n,count; double n; while(scanf("%lf",&n)!=EOF){ count=0; sq_n=sqrt(n); for(i=0;i<n;i++) prime[i]=1; prime[0]=0; for(i=1;i<sq_n;i++){ if(prime[i]==1){ for(j=(i+1);(i+1)*j<=n;j++) { prime[(i+1)*j-1]=0; } } } for(i=0;i<n;i++){ if(prime[i]==1){ count++; } } printf("%d\n",count); } return 0; }
main.c: In function 'main': main.c:6:11: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 6 | while(scanf("%lf",&n)!=EOF){ | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | int main(void){ main.c:6:11: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 6 | while(scanf("%lf",&n)!=EOF){ | ^~~~~ main.c:6:11: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:6:28: error: 'EOF' undeclared (first use in this function) 6 | while(scanf("%lf",&n)!=EOF){ | ^~~ main.c:6:28: note: 'EOF' is defined in header '<stdio.h>'; this is probably fixable by adding '#include <stdio.h>' main.c:6:28: note: each undeclared identifier is reported only once for each function it appears in main.c:8:14: error: implicit declaration of function 'sqrt' [-Wimplicit-function-declaration] 8 | sq_n=sqrt(n); | ^~~~ main.c:1:1: note: include '<math.h>' or provide a declaration of 'sqrt' +++ |+#include <math.h> 1 | int main(void){ main.c:8:14: warning: incompatible implicit declaration of built-in function 'sqrt' [-Wbuiltin-declaration-mismatch] 8 | sq_n=sqrt(n); | ^~~~ main.c:8:14: note: include '<math.h>' or provide a declaration of 'sqrt' main.c:10:13: error: 'prime' undeclared (first use in this function) 10 | prime[i]=1; | ^~~~~ main.c:25:9: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 25 | printf("%d\n",count); | ^~~~~~ main.c:25:9: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:25:9: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:25:9: note: include '<stdio.h>' or provide a declaration of 'printf'
s063989421
p00009
C
#include "sort.h" int main() { int n; int result; while(scanf("%d",&n)!=EOF) { if(n <= 1) printf("Error input!"); else if(n == 2) { result = 1; } else if(n == 3) { result = 2; } else { result = n - function(n) - 1; } printf("%d\n",result); } return 0; } int function(n) { int i,j; int count = 0; for(i=2;i<=n;i++) { for(j=2;j<=(int)sqrt(i);j++) { if(i%j == 0) { count++; break; } } } return count; }
main.c:1:10: fatal error: sort.h: No such file or directory 1 | #include "sort.h" | ^~~~~~~~ compilation terminated.
s892444638
p00009
C
#include<stdio.h> int main(void) { int a,j,i; while(scanf("%d",&a)!=EOF){ int b=0,count=0; for(j=2;j<=a;j++){ for(i=2;i<a;i++){ if(a%i=0) b=1; } if(b==0) count+=1; } printf("%d\n",count); } return 0; }
main.c: In function 'main': main.c:11:15: error: lvalue required as left operand of assignment 11 | if(a%i=0) | ^
s204272181
p00009
C
#include <stdio.h> int main(){ int sosuu[100000] = { 2, 3, 5 }, i, x, y = 3,n,z; while (scanf("%d", &n) ! = EOF){ z = 0; for (i = 3; i < n + 1; i += 2){ for (x = 0; x < y; x++){ if (i % sosuu[x] == 0){ break; } if (x + 1 == y){ sosuu[y] = i, y++;} } } for (i = 0; i < y; i++){ if (sosuu[i] > n)break; z++; } printf("%d\n", z); } return 0; }
main.c: In function 'main': main.c:6:31: error: expected ')' before '!' token 6 | while (scanf("%d", &n) ! = EOF){ | ~ ^ ~ | )
s294022656
p00009
C
#include <stdio.h> int main(void){ int n; while(true){ scanf("%d",n); if(n==EOF){ break; } int m; bool check=true; for(m=2;m<n-1;m++){ if(n%m==0){ check=false; break; } } if(check==true){ printf("%d",n); return 0; }
main.c: In function 'main': main.c:5:7: error: 'true' undeclared (first use in this function) 5 | while(true){ | ^~~~ main.c:2:1: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' 1 | #include <stdio.h> +++ |+#include <stdbool.h> 2 | main.c:5:7: note: each undeclared identifier is reported only once for each function it appears in 5 | while(true){ | ^~~~ main.c:11:1: error: unknown type name 'bool' 11 | bool check=true; | ^~~~ main.c:11:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' main.c:14:7: error: 'false' undeclared (first use in this function) 14 | check=false; | ^~~~~ main.c:14:7: note: 'false' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' main.c:21:1: error: expected declaration or statement at end of input 21 | } | ^ main.c:21:1: error: expected declaration or statement at end of input
s189032913
p00009
C
#include <stdio.h> int main(void){ int n; while(true){ scanf("%d",n); if(n==EOF){ break; } int m; boolean check=true; for(m=2;m<n-1;m++){ if(n%m==0){ check=false; break; } } if(check==true){ printf("%d",n); return 0; }
main.c: In function 'main': main.c:5:7: error: 'true' undeclared (first use in this function) 5 | while(true){ | ^~~~ main.c:2:1: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' 1 | #include <stdio.h> +++ |+#include <stdbool.h> 2 | main.c:5:7: note: each undeclared identifier is reported only once for each function it appears in 5 | while(true){ | ^~~~ main.c:11:1: error: unknown type name 'boolean' 11 | boolean check=true; | ^~~~~~~ main.c:14:7: error: 'false' undeclared (first use in this function) 14 | check=false; | ^~~~~ main.c:14:7: note: 'false' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' main.c:21:1: error: expected declaration or statement at end of input 21 | } | ^ main.c:21:1: error: expected declaration or statement at end of input
s787611289
p00009
C
#include <stdio.h> int main(void){ int n; while(true){ scanf("%d",n); if(n==EOF){ break; } int m; bool check=true; for(m=2;m<n-1;m++){ if(n%m==0){ check=false; break; } } if(check==true){ printf("%d",n); } } return 0; }
main.c: In function 'main': main.c:5:7: error: 'true' undeclared (first use in this function) 5 | while(true){ | ^~~~ main.c:2:1: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' 1 | #include <stdio.h> +++ |+#include <stdbool.h> 2 | main.c:5:7: note: each undeclared identifier is reported only once for each function it appears in 5 | while(true){ | ^~~~ main.c:11:1: error: unknown type name 'bool' 11 | bool check=true; | ^~~~ main.c:11:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' main.c:14:7: error: 'false' undeclared (first use in this function) 14 | check=false; | ^~~~~ main.c:14:7: note: 'false' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
s823544882
p00009
C
#include <stdio.h> int main(void){ int n; while(true){ scanf("%d",n); if(n==EOF){ break; } int m; int check=1; for(m=2;m<n-1;m++){ if(n%m==0){ check=0; break; } } if(check==1){ printf("%d",n); } } return 0; }
main.c: In function 'main': main.c:5:7: error: 'true' undeclared (first use in this function) 5 | while(true){ | ^~~~ main.c:2:1: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' 1 | #include <stdio.h> +++ |+#include <stdbool.h> 2 | main.c:5:7: note: each undeclared identifier is reported only once for each function it appears in 5 | while(true){ | ^~~~
s109064284
p00009
C
#include <stdio.h> int main(void){ int n; while(true){ scanf("%d",n); if(n==-1){ break; } int m; int check=1; for(m=2;m<n-1;m++){ if(n%m==0){ check=0; break; } } if(check==1){ printf("%d",n); } } return 0; }
main.c: In function 'main': main.c:5:7: error: 'true' undeclared (first use in this function) 5 | while(true){ | ^~~~ main.c:2:1: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' 1 | #include <stdio.h> +++ |+#include <stdbool.h> 2 | main.c:5:7: note: each undeclared identifier is reported only once for each function it appears in 5 | while(true){ | ^~~~
s117918856
p00009
C++
#include <iostream> using namespace std; const int max=500000; int prime[max]; int main() { ios::sync_with_stdio(false); cin.tie(0); for(int i=0; i<max; i++) prime[i]=1; for(int i=3; i<1000; i+=2) { if(!prime[i>>1]) continue; for(int j=(i*i)/2; j<max; j+=i) prime[j]=0; } for(int i=1; i<max; i++) prime[i]+=prime[i-1]; int n; while(cin>>n) { cout<<prime[(n-1)/2]<<'\n'; } return 0; }
a.cc:5:11: error: reference to 'max' is ambiguous 5 | int prime[max]; | ^~~ In file included from /usr/include/c++/14/string:51, 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_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:4:11: note: 'const int max' 4 | const int max=500000; | ^~~ a.cc: In function 'int main()': a.cc:10:20: error: reference to 'max' is ambiguous 10 | for(int i=0; i<max; i++) prime[i]=1; | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:4:11: note: 'const int max' 4 | const int max=500000; | ^~~ a.cc:10:30: error: 'prime' was not declared in this scope 10 | for(int i=0; i<max; i++) prime[i]=1; | ^~~~~ a.cc:12:13: error: 'prime' was not declared in this scope 12 | if(!prime[i>>1]) continue; | ^~~~~ a.cc:13:30: error: reference to 'max' is ambiguous 13 | for(int j=(i*i)/2; j<max; j+=i) prime[j]=0; | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:4:11: note: 'const int max' 4 | const int max=500000; | ^~~ a.cc:13:41: error: 'prime' was not declared in this scope 13 | for(int j=(i*i)/2; j<max; j+=i) prime[j]=0; | ^~~~~ a.cc:15:20: error: reference to 'max' is ambiguous 15 | for(int i=1; i<max; i++) prime[i]+=prime[i-1]; | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:4:11: note: 'const int max' 4 | const int max=500000; | ^~~ a.cc:15:30: error: 'prime' was not declared in this scope 15 | for(int i=1; i<max; i++) prime[i]+=prime[i-1]; | ^~~~~ a.cc:18:15: error: 'prime' was not declared in this scope 18 | cout<<prime[(n-1)/2]<<'\n'; | ^~~~~
s408329465
p00009
C++
#include<iostream> using namespace std; int n; int a[1000000]; int sum[1000000]; int main(int argc, char const *argv[]) { for (int i = 2; i < 1000000; ++i) { if (!a[i]) for (int j = i*2; j < 1000000; j+=i) a[j]=1; } for (int i = 2; i <1000000 ; ++i) sum[i]=sum[i-1]+(a[i]==0?1:0); while (cin>>n) cout<<sum[n]<<endl; return 0; } }
a.cc:26:9: error: expected declaration before '}' token 26 | } | ^
s526653169
p00009
C++
#include<bits/stdc++.h> using namespace std; #define maxPN 1000000 #define PNs 1000100 int countPN = 0, countPNs = 0; long long PrimeNum[maxPN], temp; bool PN[PNs]; bool IsPrimeNumber(long long x); void PrimeN(){ int i, j; PrimeNum[0] = 2; PN[2] = true;PrimeNum[countPN++] = 2; PN[3] = true;PrimeNum[countPN++] = 3; // PN[5] = true;PrimeNum[countPN++] = 5; for(i = 6; i < PNs;i+=6){ if(IsPrimeNumber(i-1)){ PrimeNum[countPN++] = i-1; PN[i-1] = true;//cout<<i-1<<endl; } if(IsPrimeNumber(i+1)){ PrimeNum[countPN++] = i+1; PN[i+1] = true;//cout<<i+1<<endl; } countPNs = i+1;//cout<<i-1<<" "<<PN[i-1]<<endl; } } bool IsPrimeNumber(long long x){ //if(x == 2 || x == 3) return true; //if(x <= 4 || x%2 == 0 || x%3 == 0) return false; //if(x < countPNs) return PN[x]; for(long long i = 0; PrimeNum[i] * PrimeNum[i] <= x; i++) if(x%PrimeNum[i] == 0)return false; return true; } int main(){ clock_t start, end; long long n = true, counta; start = clock(); PrimeN(); // cout<<PrimeNum[countPN-1]<<" "<<countPNs<<endl; // cout<<clock()-start<<"ms"<<endl; while(cin>>n){ counta = 1; //cout<<(IsPrimeNumber(n)?"yes":"no")<<endl; start = clock(); //cout<<IsPrimeNumber(n)<<endl; for(int i = 1; i <= n; i+=2){ if(PN[i])counta++; // cout<<i<<" "<<PN[i]<<endl; } if(n == 1) counta = 0; cout<<counta<<endl; // cout<<clock()-start<<"ms"<<endl; } return 0;
a.cc: In function 'int main()': a.cc:65:14: error: expected '}' at end of input 65 | return 0; | ^ a.cc:42:11: note: to match this '{' 42 | int main(){ | ^
s272401758
p00009
C++
import math import sys def prime_calc(n): rootN = math.floor(math.sqrt(n)) prime = [2] data = [i + 1 for i in range(2,n,2)] while True: p = data[0] if rootN < p: return len(prime + data) prime.append(p) data = [e for e in data if e % p != 0] def main(): l = [] for line in sys.stdin: l.append(line) for line in l: print(prime_calc(line)) if __name__ == "__main__": main()
a.cc:1:1: error: 'import' does not name a type 1 | import math | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
s865438473
p00009
C++
import math import sys def prime_calc(n): rootN = int(n**0.5) prime = [2] data = [i + 1 for i in range(2,n,2)] while True: p = data[0] if rootN <= p: return len(prime + data) prime.append(p) data = [e for e in data if e % p != 0] def main(): l = [] for line in sys.stdin: l.append(line) for line in l: print(prime_calc(line)) if __name__ == "__main__": main()
a.cc:1:1: error: 'import' does not name a type 1 | import math | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
s285903044
p00009
C++
import math import sys def prime_calc(n): rootN = math.floor(math.sqrt(n)) prime = [2] data = [i + 1 for i in range(2,n,2)] while True: p = data[0] if rootN <= p: return len(prime + data) prime.append(p) data = [e for e in data if e % p != 0] def main(): l = [] for line in sys.stdin: l.append(line) for line in l: print(prime_calc(line)) if __name__ == "__main__": main()
a.cc:1:1: error: 'import' does not name a type 1 | import math | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
s696511407
p00009
C++
#include<stdio.h> int prime[1000000]; int main(){ prime[0]=-1; prime[1]=-1; for(int i=2;i<1000000;i++){ if(prime[i]==0){ prime[i]=1; for(int j=i*2;j<1000000;j+=i)prime[j]=-1; } } int now; while(~scanf("%d",&now)){ int ans=0; for(int i=1;i<now+1;i++)if(prime[i]==1)ans++; printf("%d\n",ans); }
a.cc: In function 'int main()': a.cc:17:6: error: expected '}' at end of input 17 | } | ^ a.cc:3:11: note: to match this '{' 3 | int main(){ | ^
s152700028
p00009
C++
nclude <iostream> #include <cstdio> #include <algorithm> #include <string> #include <cstring> #include <cctype> #include <cmath> #include <stack> #include <queue> #include <vector> #include <set> #include <map> #include <list> #include <stdio.h> #include <string.h> #include <cstdlib> #include <math.h> #include <bitset> #include <iterator> #include <iomanip> #include <sstream> #include <numeric> #define INF 2000000000 using namespace std; int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1}; long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);} long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;} long long MOD; template<class T> void mod(T &n){MOD=n;} #define sym cout<<"---------"<<endl; #define ll long long #define PL pair<long long, long long> #define P pair<int,int> #define mk make_pair #define en endl #define WHITE 1 #define BLACK 2 #define GRAY 1 #define RE return 0 #define int ll bool prime[1000005]={true}; signed main(){ int n; while(cin>>n){ if(n==1){cout<<0<<en; continue;} for(int i=2; i<=n; i++) prime[i]=true; int ans=0; for(int i=2; i<=n; i++){ if(prime[i]) { ans++; for(int j=2*i; j<=n; j+=i) prime[j]=false; } } cout<<ans<<en; } }
a.cc:1:1: error: 'nclude' does not name a type 1 | nclude <iostream> | ^~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:62, from /usr/include/c++/14/algorithm:60, from a.cc:3: /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: /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/stdio.h:34, from /usr/include/c++/14/cstdio:42, from a.cc:2: /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; did you mean 'en'? 2176 | unsigned char __data[_Len]; | ^~~~ | en /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; did you mean 'en'? 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^~~~ | en /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; did you mean 'en'? 2202 | unsigned char __data[_Len]; | ^~~~ | en /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/in
s851132548
p00009
C++
#include <stdio.h> #include <math.h> int primes[78498], num_primes = 1; int calculated = 2; int count_pos(int n) { for (int i = 0; i < num_primes; i++) { if (primes[i] == n) { return i + 1; } else if (primes[i] > n) { return i; } } return num_primes; } int main() { primes[0] = 2; while (true) { int n; if (!scanf_s("%d", &n)) break; if (calculated+1 < n) { for (int i = calculated + 1; i < n + 1; i += 2) { bool is_prime = true; for (int w = 3; w < (int)(sqrt(i)) + 1; w += 2) { if (i%w == 0) { is_prime = false; break; } } if (is_prime) { primes[num_primes++] = i; } } calculated = n - (n % 2); } printf("%d\n", count_pos(n)); } }
a.cc: In function 'int main()': a.cc:21:22: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'? 21 | if (!scanf_s("%d", &n)) break; | ^~~~~~~ | scanf
s545388254
p00009
C++
int primes[78498], num_primes; int calculated; int count_pos(int n) { for (int i = 0; i < num_primes; i++) { if (primes[i] == n) { return i + 1; } else if (primes[i] > n) { return i; } } return num_primes; } int main() { primes[0] = 2; calculated = 2; num_primes = 1; while (true) { int n; if (!scanf_s("%d", &n)) break; if (calculated+1 < n) { for (int i = calculated + 1; i < n + 1; i += 2) { bool is_prime = true; int max = (int)(sqrt(i)) + 1; for (int j=1; primes[j] < max&&j<num_primes; j++) { if (i%primes[j] == 0) { is_prime = false; break; } } if (is_prime) { primes[num_primes++] = i; } } calculated = n - (n % 2); } printf("%d\n", count_pos(n)); } }
a.cc: In function 'int main()': a.cc:20:22: error: 'scanf_s' was not declared in this scope 20 | if (!scanf_s("%d", &n)) break; | ^~~~~~~ a.cc:24:49: error: 'sqrt' was not declared in this scope 24 | int max = (int)(sqrt(i)) + 1; | ^~~~ a.cc:37:17: error: 'printf' was not declared in this scope 37 | printf("%d\n", count_pos(n)); | ^~~~~~ a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' +++ |+#include <cstdio> 1 | int primes[78498], num_primes;
s177957932
p00009
C++
int primes[78498], num_primes; int calculated; int count_pos(int n) { for (int i = 0; i < num_primes; i++) { if (primes[i] == n) { return i + 1; } else if (primes[i] > n) { return i; } } return num_primes; } int main() { primes[0] = 2; calculated = 2; num_primes = 1; while (true) { int n; if (!scanf("%d", &n)) break; if (calculated+1 < n) { for (int i = calculated + 1; i < n + 1; i += 2) { bool is_prime = true; int max = (int)(sqrt(i)) + 1; for (int j=1; primes[j] < max&&j<num_primes; j++) { if (i%primes[j] == 0) { is_prime = false; break; } } if (is_prime) { primes[num_primes++] = i; } } calculated = n - (n % 2); } printf("%d\n", count_pos(n)); } }
a.cc: In function 'int main()': a.cc:20:22: error: 'scanf' was not declared in this scope 20 | if (!scanf("%d", &n)) break; | ^~~~~ a.cc:24:49: error: 'sqrt' was not declared in this scope 24 | int max = (int)(sqrt(i)) + 1; | ^~~~ a.cc:37:17: error: 'printf' was not declared in this scope 37 | printf("%d\n", count_pos(n)); | ^~~~~~ a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' +++ |+#include <cstdio> 1 | int primes[78498], num_primes;
s551541168
p00009
C++
#include<bits/stdc++.h> bool f[1000005]; int tot[1000003]; int main() { memset(f,true,sizeof(f)); for(int i=2;i<=1000;i++) { if (f[i]) { for(int j=i+i;j<=1000000;j=j+i) { f[j]=false; } } } for(int i=2;i<=1000000;i++) { if(f[i]) { tot[i]=tot[i-1]+1; } else tot[i]=tot[i-1]; } int in; while(cin>>in) cout<<tot[in]<<endl; }
a.cc: In function 'int main()': a.cc:26:11: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 26 | while(cin>>in) cout<<tot[in]<<endl; | ^~~ | std::cin In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146, 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:26:20: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 26 | while(cin>>in) cout<<tot[in]<<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:26:35: error: 'endl' was not declared in this scope; did you mean 'std::endl'? 26 | while(cin>>in) cout<<tot[in]<<endl; | ^~~~ | std::endl In file included from /usr/include/c++/14/istream:41, from /usr/include/c++/14/sstream:40, from /usr/include/c++/14/complex:45, from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127: /usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here 744 | endl(basic_ostream<_CharT, _Traits>& __os) | ^~~~
s688120829
p00009
C++
#include <iostream> #include<string> #include<cmath> #include<algorithm> #include<cctype> #include<queue> #include<stack> #include<stdio.h> #include<vector> #include<set> #include<map> #include<iomanip> #define rep(i,n) for(int i=0;i<n;i++) typedef int long long ll; using namespace std; /*int main(){ ll n; while (cin>>n) { vector<ll> v; for(int i=0;i<n+1;i++){ v.push_back(i); } ll b=v[v.size()-1]; for(int i=2;i<=n;i++){ ll j=2; while(i*j<=b){ v[i*j]=0; j++; } } ll ans=0; for(int i=0;i<v.size();i++){ // cout<<v[i]<<endl; if(v[i]!=0)ans++; } cout<<ans-1<<endl; } return 0; }*/ int main(){ ll n; while(cin>>n){ /* ll ans=0; for(int i=3;i<=n;i+=2){ int flag=0; for(int j=3;j<=sqrt(i);j+=2){ if(i%j==0){ flag=1; break; } } if(flag==0){ ans++; } } cout<<ans+1<<endl;*/ vector<bool> IsPrime; if(n+1>IsPrime.size()){ IsPrime.resize(n+1,true); } IsPrime[0]=false; IsPrime[1]=false; for(int i=2;i<=sqrt(n);i++){ if(IsPrime[I]){ for(ll j=2;i*j<=n;++j){ IsPrime[i*j]=false; } } } ll ans=0; for(int i=0;i<IsPrime.size();i++){ if(IsPrime[i])ans++; } cout<<ans<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:70:24: error: 'I' was not declared in this scope 70 | if(IsPrime[I]){ | ^
s117481020
p00009
C++
#include <iostream> #include<string> #include<cmath> #include<algorithm> #include<cctype> #include<queue> #include<stack> #include<stdio.h> #include<vector> #include<set> #include<map> #include<iomanip> #define rep(i,n) for(int i=0;i<n;i++) typedef int long long ll; using namespace std; /*int main(){ ll n; while (cin>>n) { vector<ll> v; for(int i=0;i<n+1;i++){ v.push_back(i); } ll b=v[v.size()-1]; for(int i=2;i<=n;i++){ ll j=2; while(i*j<=b){ v[i*j]=0; j++; } } ll ans=0; for(int i=0;i<v.size();i++){ // cout<<v[i]<<endl; if(v[i]!=0)ans++; } cout<<ans-1<<endl; } return 0; }*/ int main(){ ll n; while(cin>>n){ /* ll ans=0; for(int i=3;i<=n;i+=2){ int flag=0; for(int j=3;j<=sqrt(i);j+=2){ if(i%j==0){ flag=1; break; } } if(flag==0){ ans++; } } cout<<ans+1<<endl;*/ vector<bool> IsPrime; if(n+1>IsPrime.size()){ IsPrime.resize(n+1,true); } IsPrime[0]=false; IsPrime[1]=false; for(int i=2;i<=sqrt(n);i++){ if(IsPrime[I]){ for(ll j=2;i*j<=n;++j){ IsPrime[i*j]=false; } } } ll ans=0; for(int i=0;i<IsPrime.size();i++){ if(IsPrime[i])ans++; } cout<<ans<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:70:24: error: 'I' was not declared in this scope 70 | if(IsPrime[I]){ | ^
s384578456
p00009
C++
#include<cstdio> #include<vector> #include<iostream> using namespace std; vector<bool> prime(1000010, 1); signed main(){ prime[0] = 0; prime[1] = 0; prime[2] = ( const ) 1; int ret = 0; int n; scanf( "%d", &n ); for( int i = 2; i * i <= n; i++ ){ if( prime[i] ){ for( int j = 1; ( j + 1 ) * i <= n; j++ ){ prime[i * ( j + 1 )] = 0; } } } for( int i = 0; i <= n; i++ ) { if( prime[i] ) { ret++; } } printf( "%d\n", ret ); return 0; }
a.cc: In function 'int main()': a.cc:10:46: error: ISO C++ forbids declaration of 'type name' with no type [-fpermissive] 10 | prime[0] = 0; prime[1] = 0; prime[2] = ( const ) 1; | ^~~~~
s577716637
p00009
C++
//↓template↓ #include "bits/stdc++.h" using namespace std; #define Would #define you #define all(n) n.begin(),n.end() const long long INF = 1e18; const long long MOD = 1e9 + 7; const double pi = acos(-1); const int SIZE = 1 << 17; int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30]; long long fac[200005], finv[200005], inv[200005]; vector<long long>dij; struct edge { long long to, cost; }; vector<vector<edge> >G; long long mod_pow(long long a, long long b) { long long res = 1, mul = a; for (int i = 0; i < 31; ++i) { if (b >> i & 1) { res *= mul; res %= MOD; } mul = (mul * mul) % MOD; } return res; } void addedge(int from, int to, int cost) { G[from].push_back({ to,cost }); G[to].push_back({ from,cost }); } //↑template↑ long long isp(long long n) { long longres; for (int i = 2; i <= sqrt(n); ++i) { if (n%i == 0) { ++res; } } return res; } int main() { long long n; while (cin >> n) { cout << isp(n) << endl; } }
a.cc: In function 'long long int isp(long long int)': a.cc:41:35: error: 'res' was not declared in this scope 41 | if (n%i == 0) { ++res; } | ^~~ a.cc:43:16: error: 'res' was not declared in this scope 43 | return res; | ^~~
s732283076
p00009
C++
#include<bits/stdc++.h> using namespace std; int main(){ int n,i; i=0; vector<int> an(1000000),as(1000000); an[0]=2; for(int j=3;j<1000000;j++){ for(int u=0;u<1000000;u++){ if(an[u]==0){ an[u]=j; break; } if(j%an[u]==0){ break; } else{ continue; } } } for(int u=1;u<1000000;u++){ if(u==an[i]){ as[u]=as[u-1]+1; } else{ as[u]=as[u-1]; } } for(int i=0;i<30;i++){ cin>>n; cout<<as[n]<<endl; }
a.cc: In function 'int main()': a.cc:34:2: error: expected '}' at end of input 34 | } | ^ a.cc:4:11: note: to match this '{' 4 | int main(){ | ^
s832651575
p00009
C++
#include<iostream> #include<algorithm> #include<vector> #include<cmath> #include<cstdio> #include<string> #include<cmath> typedef long long int ll; using namespace std; bool priN[1000000]={}; bool pri[1000000]={}; bool isPrime(int n){ if(priN[n]==true)return pri[n]; for(int i=3;i<=sqrt((double)n);i++){ if(n%i==0){ priN[n]=true; pri[n]=false; return false; } } priN[n]=true; pri[n]=true; return true; } int main(){ while(1){ int n; if( !(cin>>n) )break; ll sum=1; if n<2 sum--; for(int i=3;i<=n;i+=2){ if(isPrime(i))sum++; } cout<<sum<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:34:20: error: expected '(' before 'n' 34 | if n<2 sum--; | ^ | (
s200790163
p00009
C++
#include<utility> #include<vector> #include<cmath> #include<cstdio> #define loop(i,a,b) for(int i=a;i<b;i++) #define rep(i,a) loop(i,0,a) #define pb push_back #define mp make_pair #define it ::iterator #define all(in) in.begin(),in.end() const double PI=acos(-1); const double ESP=1e-10; using namespace std; #define MAX 1000000 bool sosu[MAX]={false}; int main(){ for(int i=3;i<MAX;i+=2){ if(sosu[i])continue; for(int j=i*3;j<MAX;j+=i*2) sosu[j]=true; } for(int i=4;i<MAX;i+=2) sosu[i]=true; int in; while(cin>>in){ int co=0; loop(i,2,in+1)if(!sosu[i])co++; cout<<co<<endl; } }
a.cc: In function 'int main()': a.cc:25:9: error: 'cin' was not declared in this scope 25 | while(cin>>in){ | ^~~ a.cc:5:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 4 | #include<cstdio> +++ |+#include <iostream> 5 | #define loop(i,a,b) for(int i=a;i<b;i++) a.cc:28:5: error: 'cout' was not declared in this scope 28 | cout<<co<<endl; | ^~~~ a.cc:28:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:28:15: error: 'endl' was not declared in this scope 28 | cout<<co<<endl; | ^~~~ a.cc:5:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 4 | #include<cstdio> +++ |+#include <ostream> 5 | #define loop(i,a,b) for(int i=a;i<b;i++)
s560589300
p00009
C++
#include <iostream> #include <algorithm> using namespace std; int count(int n); int main(void){ while (true){ int n; cin >> n; if (!n){ break; } cout << count(n) << endl; } return 0; } int count(int n){ int ct = 0; int *prime = new int[n]; for (int i = 0; i <= n;i++){ prime[i] = 0; } prime[2] = 1; for (int i = 3; i <= n; i = i + 2){ prime[i] = 1; } for (int i = 3; i <= sqrt(n); i = i + 2){ if (prime[i] == 0) continue; for (int j = i * 2; j <= n; j = j + i){ prime[j] = 0; } } for (int i = 3; i <= n; i = i + 2){ if (prime[i] == 1) ct++; } ct++; //2を数えていない分 return ct; delete[] prime; }
a.cc: In function 'int count(int)': a.cc:28:30: error: 'sqrt' was not declared in this scope 28 | for (int i = 3; i <= sqrt(n); i = i + 2){ | ^~~~
s167255469
p00009
C++
#include <iostream> using namespace std; int count(int n); int main(void){ while (true){ int n; cin >> n; if (!n){ break; } cout << count(n) << endl; } return 0; } int count(int n){ int ct = 0; //bool *prime = new bool[n]; bool prime[999999]; for (int i = 0; i <= n;i++){ prime[i] = 0; } prime[2] = 1; for (int i = 3; i <= n; i = i + 2){ prime[i] = 1; } for (int i = 3; i <= sqrt(n); i = i + 2){ if (prime[i] == 0) continue; for (int j = i * 2; j <= n; j = j + i){ prime[j] = 0; } } for (int i = 3; i <= n; i = i + 2){ if (prime[i] == 1) ct++; } ct++; //2を数えていない分 return ct; //delete[] prime; }
a.cc: In function 'int count(int)': a.cc:28:30: error: 'sqrt' was not declared in this scope 28 | for (int i = 3; i <= sqrt(n); i = i + 2){ | ^~~~
s917677531
p00009
C++
#include <iostream> using namespace std; int count(int n); int main(void){ while (true){ int n; cin >> n; if (!n){ break; } cout << count(n) << endl; } return 0; } int count(int n){ int ct = 0; bool *prime = new bool[n]; //bool prime[999999]; for (int i = 0; i <= n;i++){ prime[i] = 0; } prime[2] = 1; for (int i = 3; i <= n; i = i + 2){ prime[i] = 1; } for (int i = 3; i <= sqrt(n); i = i + 2){ if (prime[i] == 0) continue; for (int j = i * 2; j <= n; j = j + i){ prime[j] = 0; } } for (int i = 3; i <= n; i = i + 2){ if (prime[i] == 1) ct++; } ct++; //2を数えていない分 delete[] prime; return ct; }
a.cc: In function 'int count(int)': a.cc:28:30: error: 'sqrt' was not declared in this scope 28 | for (int i = 3; i <= sqrt(n); i = i + 2){ | ^~~~
s458474305
p00009
C++
#include <iostream> #include <algorithm> using namespace std; int count(int n); int main(void){ while (true){ int n; cin >> n; if (!n){ break; } cout << count(n) << endl; } return 0; } int count(int n){ int ct = 0; bool *prime = new bool[n]; //bool prime[999999]; for (int i = 0; i <= n;i++){ prime[i] = 0; } prime[2] = 1; for (int i = 3; i <= n; i = i + 2){ prime[i] = 1; } for (int i = 3; i <= sqrt(n); i = i + 2){ if (prime[i] == 0) continue; for (int j = i * 2; j <= n; j = j + i){ prime[j] = 0; } } for (int i = 3; i <= n; i = i + 2){ if (prime[i] == 1) ct++; } ct++; //2を数えていない分 return ct; delete[] prime; }
a.cc: In function 'int count(int)': a.cc:29:30: error: 'sqrt' was not declared in this scope 29 | for (int i = 3; i <= sqrt(n); i = i + 2){ | ^~~~
s203433856
p00009
C++
#include <iostream> #include <algorithm> using namespace std; int count(int n); int main(void){ while (true){ int n; cin >> n; if (!n){ break; } cout << count(n) << endl; } return 0; } int count(int n){ int ct = 0; bool *prime = new bool[n]; //bool prime[999999]; for (int i = 0; i <= n;i++){ prime[i] = 0; } prime[2] = 1; for (int i = 3; i <= n; i = i + 2){ prime[i] = 1; } for (int i = 3; i <= sqrt(n * 1.0); i = i + 2){ if (prime[i] == 0) continue; for (int j = i * 2; j <= n; j = j + i){ prime[j] = 0; } } for (int i = 3; i <= n; i = i + 2){ if (prime[i] == 1) ct++; } ct++; //2を数えていない分 return ct; delete[] prime; }
a.cc: In function 'int count(int)': a.cc:29:30: error: 'sqrt' was not declared in this scope 29 | for (int i = 3; i <= sqrt(n * 1.0); i = i + 2){ | ^~~~
s467669897
p00009
C++
#include <iostream> #include <vector> using namespace std; int main() { const int N = 1000000; vector<bool> vec(N, true); double limit = sqrt(N); for (int i = 2; i < limit; i++){ for (int j = 2; i * j < N; j++){ vec[i * j] = false; } } int n, cnt = 0; while (cin >> n){ for (int i = 2; i <= n; i++){ if (vec[i])cnt++; } cout << cnt << endl; cnt = 0; } }
a.cc: In function 'int main()': a.cc:9:24: error: 'sqrt' was not declared in this scope 9 | double limit = sqrt(N); | ^~~~
s557882471
p00009
C++
#include<stdio.h> #include<string.h> #define range 999999 int total_added = 4; struct primes{ int key; int counts; }; primes p[range]; bool is_prime(int key) { int i; for (i = 2; i <= sqrt(key); i++) { if (key%i == 0)return false; } return true; } void init() { p[0].key = 2; p[0].counts = 1; p[1].key = 3; p[1].counts = 2; p[2].key = 5; p[2].counts = 3; p[3].key = 7; p[3].counts = 4; int i; for (i = 8; i <= range; i++) { if (i % 2 != 0&&i%3!=0&&i%5!=0) { if (is_prime(i)) { p[total_added].key = i; p[total_added].counts = p[total_added - 1].counts + 1; total_added++; } } } } int counting_result(int key) { for (int i =total_added-1; i>=0; i--) { if (key >= p[i].key) return p[i].counts; } return 0; } int main() { init(); int i=0, n; while (i<30) { scanf("%d", &n); printf("%d\n",counting_result(n)); i++; } }
a.cc: In function 'bool is_prime(int)': a.cc:14:26: error: 'sqrt' was not declared in this scope 14 | for (i = 2; i <= sqrt(key); i++) | ^~~~
s598925626
p00009
C++
#include <cstdio> #include <cstdlib> #include <cmath> #include <string> #include <algorithm> using namespace std; int main(){ int j,s[1000000]=0; long i,n,d=0; for(i=3;i<1000000;i++){ for(j=2;j*j<i;j+=2){ if(j%i==0){ d--; break; } if(j==2) j=1; } s[i] = ++d; } while(EOF != scanf("%d",&n)){ printf("%d\n",&d); } return 0; }
a.cc: In function 'int main()': a.cc:11:22: error: array must be initialized with a brace-enclosed initializer 11 | int j,s[1000000]=0; | ^
s839809824
p00009
C++
#include <iostream > using namespace std; int main() { for (int i=0; i<=30; i++) { int N; cin >> N; int count = 0; for (int i = 1; i <= N; ++i) { bool isPrime = true ; for (int j = 2; j < i; ++j) { if (i % j == 0) { isPrime = false ; break ; } } if (isPrime) { --N; count++; } } cout << count << endl; } return 0; }
a.cc:1:11: fatal error: iostream : No such file or directory 1 | #include <iostream > | ^~~~~~~~~~~ compilation terminated.
s374360655
p00009
C++
#include <iostream> #include <list> #include <algorithm> int main(){ int NUM; while(std::cin >> NUM){ std::list<int> numList,primeList; for(int i=2;i<=NUM;++i){ numList.push_back(i); } for(int i=numList.front();i<std::sqrt(NUM);i=numList.front()){ primeList.push_back(i); numList.erase(std::remove_if(numList.begin(),numList.end(),[&](int num){return num%i==0;}),numList.end()); } int cnt=numList.size()+primeList.size(); std::printf("%d\n",cnt); } return 0; }
a.cc: In function 'int main()': a.cc:13:50: error: 'sqrt' is not a member of 'std'; did you mean 'sort'? 13 | for(int i=numList.front();i<std::sqrt(NUM);i=numList.front()){ | ^~~~ | sort
s734619230
p00009
C++
#include <iostream> #include <cmath> using namespace std; int prime(int); int main(){ int a,n; n=0; while ( cin >> a){ for (int i=2;i<a;i++){ if (prime(i)==0){ n++; } } cout << n << endl; } } int prime(int x){ if(x==2 || x==3 || x==5 || x==7) return 0; if(x%2==0 || x%3==0 || x%5==0) return 1; for (int i=7;i<=sqrt(x)+2;i+=30){ if(x%i==0 || x%(i+4)==0 || x%(i+6)==0 || x%(i+12)==0 || x%(i+16)==0 || x%(i+22)==0 || x%(i+24) return 1; } return 0; }
a.cc: In function 'int prime(int)': a.cc:25:103: error: expected ';' before 'return' 25 | if(x%i==0 || x%(i+4)==0 || x%(i+6)==0 || x%(i+12)==0 || x%(i+16)==0 || x%(i+22)==0 || x%(i+24) | ^ | ; 26 | return 1; | ~~~~~~ a.cc:27:5: error: expected primary-expression before '}' token 27 | } | ^ a.cc:26:22: error: expected ')' before '}' token 26 | return 1; | ^ | ) 27 | } | ~ a.cc:25:11: note: to match this '(' 25 | if(x%i==0 || x%(i+4)==0 || x%(i+6)==0 || x%(i+12)==0 || x%(i+16)==0 || x%(i+22)==0 || x%(i+24) | ^ a.cc:27:5: error: expected primary-expression before '}' token 27 | } | ^
s276973647
p00009
C++
#include <iostream> #include <vector> #include <algorithm> int main() { int n; while (std::cin >> n) { std::vector<int> nums; ++n; for (int i = 0; i < n; ++i) { nums.push_back(i); } for (int i = 0; i < n; ++i) { if (nums.at(i) < 2) continue; for (int j = nums.at(i) * 2; j < n; j += nums.at(i)) { nums.at(j) = 0; } } for (int i = 0; i < n; ++i) { if (nums.at(i) > 1) { ++c } } } return 0; }
a.cc: In function 'int main()': a.cc:22:35: error: 'c' was not declared in this scope 22 | ++c | ^
s711372547
p00009
C++
#include <iostream> using namespace std; int a[999999]={}; int main(){ int n,ans=0; vector<int> v; for(int i = 2; i*i < 999999; i++){ for(int j = 0; j < 999999; j+=i){ if(i!=j) a[j]=1; } } while(cin >> n){ v.push_back(n); } for(int i = 0; i < v.size(); i++){ for(int j = 2; j <= v[i]; j++){ if(a[j]==0) ans++; } cout << ans << endl; ans=0; } }
a.cc: In function 'int main()': a.cc:8:9: error: 'vector' was not declared in this scope 8 | vector<int> v; | ^~~~~~ a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>' 1 | #include <iostream> +++ |+#include <vector> 2 | using namespace std; a.cc:8:16: error: expected primary-expression before 'int' 8 | vector<int> v; | ^~~ a.cc:15:17: error: 'v' was not declared in this scope 15 | v.push_back(n); | ^ a.cc:17:28: error: 'v' was not declared in this scope 17 | for(int i = 0; i < v.size(); i++){ | ^
s498068729
p00009
C++
__bowl1 = Array.new __bowl2 = Array.new __bowl3 = Array.new __bowl4 = Array.new __bowl5 = Array.new india = gets.chomp.to_i loop do srilanka = gets.chomp.to_i __bowl.push(srilanka) thai = gets.chomp.to_i puts __bowl.pop - thai india -= 1 if india == 0 break end end
a.cc:1:1: error: '__bowl1' does not name a type 1 | __bowl1 = Array.new | ^~~~~~~
s816413279
p00009
C++
__bowl1 = Array.new __bowl2 = Array.new __bowl3 = Array.new __bowl4 = Array.new __bowl5 = Array.new india = gets.chomp.to_i loop do srilanka = gets.chomp.to_i __bowl.push(srilanka) thai = gets.chomp.to_i puts __bowl.pop - thai india -= 1 if india == 0 break end end
a.cc:1:1: error: '__bowl1' does not name a type 1 | __bowl1 = Array.new | ^~~~~~~
s979461580
p00009
C++
#include <stdio.h> int isprime(int n){ for(int = 2; i * i <= n; i++) { if(n % i == 0) return 0; //素数でない } return 1; //素数である } int main() { int n; int ans[2] = {}; while(scanf("%d", &n) != 0) { for(int i = n; i >= 5; i--) { if(isprime(i) == 1) { ans[0] = i; if(isprime(i - 2) == 1) { ans[1] = i - 2; break; } } } printf("%d %d", ans[0], ans[1]); } }
a.cc: In function 'int isprime(int)': a.cc:4:13: error: expected unqualified-id before '=' token 4 | for(int = 2; i * i <= n; i++) { | ^ a.cc:4:12: error: expected ';' before '=' token 4 | for(int = 2; i * i <= n; i++) { | ^~ | ; a.cc:4:13: error: expected primary-expression before '=' token 4 | for(int = 2; i * i <= n; i++) { | ^ a.cc:4:18: error: 'i' was not declared in this scope 4 | for(int = 2; i * i <= n; i++) { | ^ a.cc:4:28: error: expected ')' before ';' token 4 | for(int = 2; i * i <= n; i++) { | ~ ^ | ) a.cc:4:30: error: 'i' was not declared in this scope 4 | for(int = 2; i * i <= n; i++) { | ^
s547052541
p00009
C++
while True: try: n=int(input()) a=[True]*(n+1) a[0]=a[1]=False for i in range(2,int(n**0.5)+1): if a[i]: for j in range(i**2,n+1,i): a[j]=False print(a.count(True)) except: break
a.cc:1:1: error: expected unqualified-id before 'while' 1 | while True: | ^~~~~
s722361177
p00009
C++
#include<iostream> #include<string> #include<algorithm> #include<vector> using namespace std; int main(){ int n,cnt=0,ans,sosu[100000]={0}; for(int i=2;i<100000;i++){ bool flag=true; for(int j=2;j<=sqrt(i);j++){ if(i%j==0)flag=false; } if(flag){ sosu[cnt]=i; cnt++; } } while(cin>>n){ ans=0,cnt=0; for(int i=2;i<=n;i++){ if(sosu[cnt]==i){ cnt++; ans++; } } cout<<ans<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:10:32: error: 'sqrt' was not declared in this scope 10 | for(int j=2;j<=sqrt(i);j++){ | ^~~~
s964868652
p00009
C++
#include <iostream> using namespace System; using namespace std; const int MAX_N =1000000; int main(){ bool sosu[MAX_N]={};//false:sosu for(int i=2;i<MAX_N;i++){ if(!sosu[i]){ for(int j=2;j*i<MAX_N;j++){ sosu[j*i]=true; } } } for(int n;cin>>n;){ int ans=0; for(int i=2;i<=n;i++){ if(!sosu[i])ans++; } cout<<ans<<endl; } return 0; }
a.cc:2:17: error: 'System' is not a namespace-name 2 | using namespace System; | ^~~~~~
s153054568
p00009
C++
#include <iostream> #include <string> using namespace std; int main() { while(1){ long int xx,sqrtx,q,count=1; long double n; cin >> n; xx=n; sqrtx = sqrt(n); long int *ar = new long int [xx]; long int *p = new long int [xx]; for(long int i=2 ; i<=xx ; i++){ // 2〜xまでの整数 ar[i]=i; } int i=2; do{ if(ar[i]!=0){ p[count]=i; count++; } for(int j=2*i ; j<=xx ; j+=i){ ar[j]=0; } i++; }while(i<sqrtx); cout << p[count-1] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:12:17: error: 'sqrt' was not declared in this scope; did you mean 'sqrtx'? 12 | sqrtx = sqrt(n); | ^~~~ | sqrtx
s290767884
p00009
C++
int count_prime( unsigned int const& n ) { if ( n <= 0 || 1000000 <= n ) return -1; std::vector<bool> memo_prime( n+1, true ); for ( unsigned int i = 2; i < n; ++i ) { for ( unsigned int j = 2; i*j <= n; ++j ) { memo_prime.at(i*j) = false; } } memo_prime.at(0) = memo_prime.at(1) = false; memo_prime.at(2) = true; return std::count( memo_prime.begin(), memo_prime.end(), true ); } int main() { int n; while( std::cin >> n) std::cout << count_prime(n) << std::endl; return 0; }
a.cc: In function 'int count_prime(const unsigned int&)': a.cc:4:10: error: 'vector' is not a member of 'std' 4 | std::vector<bool> memo_prime( n+1, true ); | ^~~~~~ a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>' +++ |+#include <vector> 1 | int count_prime( unsigned int const& n ) a.cc:4:17: error: expected primary-expression before 'bool' 4 | std::vector<bool> memo_prime( n+1, true ); | ^~~~ a.cc:9:13: error: 'memo_prime' was not declared in this scope 9 | memo_prime.at(i*j) = false; | ^~~~~~~~~~ a.cc:12:5: error: 'memo_prime' was not declared in this scope 12 | memo_prime.at(0) = memo_prime.at(1) = false; | ^~~~~~~~~~ a.cc:14:17: error: 'count' is not a member of 'std' 14 | return std::count( memo_prime.begin(), memo_prime.end(), true ); | ^~~~~ a.cc: In function 'int main()': a.cc:20:17: error: 'cin' is not a member of 'std' 20 | while( std::cin >> n) | ^~~ a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' +++ |+#include <iostream> 1 | int count_prime( unsigned int const& n ) a.cc:21:14: error: 'cout' is not a member of 'std' 21 | std::cout << count_prime(n) << std::endl; | ^~~~ a.cc:21:14: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:21:45: error: 'endl' is not a member of 'std' 21 | std::cout << count_prime(n) << std::endl; | ^~~~ a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' +++ |+#include <ostream> 1 | int count_prime( unsigned int const& n )
s454514161
p00009
C++
#include <algorithm> #include <cstdio> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <vector> using namespace std; constexpr int LIM = 1000000; static char isprime[LIM]; static int numofprime[LIM]; void setprime(int N) { fill(isprime, isprime + N + 1, 1); isprime[0] = isprime[1] = 0; for(int x = 2, lim = (int)sqrt(N); x <= lim; ++x) { if(isprime[x]) { for(int y = x * x; y <= N; y += x) { isprime[y] = 0; } } } numofprime[0] = 0; for(int x = 0; x < N; ++x) { numofprime[x + 1] = numofprime[x] + isprime[x + 1]; } } int main() { setprime(999999); int n; while(scanf("%d", &n) != EOF) { printf("%d\n", numofprime[n]); } return 0; }
a.cc: In function 'void setprime(int)': a.cc:19:31: error: 'sqrt' was not declared in this scope 19 | for(int x = 2, lim = (int)sqrt(N); x <= lim; ++x) { | ^~~~
s611593332
p00009
C++
#include <iostream> int main(int argc, const char * argv[]) { // insert code here... while(true) { int n; std::cin >> n; if(std::cin.eof())break; int count = 0; std: for(int i=2;i<n;i++) { bool flag = true; for(int j=2;j<i/j+1;j++) { if(i%j==0) { flag=false; break;#include <iostream> int main(int argc, const char * argv[]) { // insert code here... while(true) { int n; std::cin >> n; if(std::cin.eof())break; int count = 0; std: for(int i=2;i<n;i++) { bool flag = true; for(int j=2;j<i/j+1;j++) { if(i%j==0) { flag=false; break; } } if(flag) { count++; } } std::cout << count <<"\n"; } return 0; } } } if(flag) { count++; } } std::cout << count <<"\n"; } return 0; }
a.cc:23:27: error: stray '#' in program 23 | break;#include <iostream> | ^ a.cc: In function 'int main(int, const char**)': a.cc:23:28: error: 'include' was not declared in this scope 23 | break;#include <iostream> | ^~~~~~~ a.cc:23:37: error: 'iostream' was not declared in this scope; did you mean 'std::iostream'? 23 | break;#include <iostream> | ^~~~~~~~ | std::iostream In file included 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/iosfwd:146:41: note: 'std::iostream' declared here 146 | typedef basic_iostream<char> iostream; | ^~~~~~~~ a.cc:24:1: error: expected primary-expression before 'int' 24 | int main(int argc, const char * argv[]) | ^~~
s985769080
p00009
C++
#coding: UTF-8 from bisect import bisect_right max_number = 1000000 prime_flag_list = [True] * max_number prime_flag_list[0] = False prime_flag_list[1] = False prime_flag_list[4::2] = [False] * len(prime_flag_list[4::2]) for i in range(3, int(max_number**0.5) + 1, 2): prime_flag_list[i*i::i] = [False] * len(prime_flag_list[i*i::i]) prime_list = [i for i in range(2, max_number) if prime_flag_list[i]] while True: try: input = int(raw_input()) except EOFError: break print bisect_right(prime_list, input)
a.cc:1:2: error: invalid preprocessing directive #coding 1 | #coding: UTF-8 | ^~~~~~ a.cc:3:1: error: 'from' does not name a type 3 | from bisect import bisect_right | ^~~~
s688455416
p00009
C++
int main(){ int i , j , n , pn , cn=0; while(cin>>n){ pn=1; for(i=3 ; i<=n ; i++){ for (j=2 ; j<i ; j++){ if (i%j==0) goto skip; } pn++; skip:; } if(n==0 || n==1 ) { cout << 0 << endl; } else { cout << pn << endl; } cn++; if(cn>=30) break; } return 0; }
a.cc: In function 'int main()': a.cc:4:15: error: 'cin' was not declared in this scope; did you mean 'cn'? 4 | while(cin>>n){ | ^~~ | cn a.cc:14:25: error: 'cout' was not declared in this scope 14 | cout << 0 << endl; | ^~~~ a.cc:14:38: error: 'endl' was not declared in this scope 14 | cout << 0 << endl; | ^~~~ a.cc:16:25: error: 'cout' was not declared in this scope 16 | cout << pn << endl; | ^~~~ a.cc:16:39: error: 'endl' was not declared in this scope 16 | cout << pn << endl; | ^~~~
s316454808
p00009
C++
int main(){ int i , j , n , pn , cn=0; while(cin>>n){ pn=1; for(i=3 ; i<=n ; i++){ for (j=2 ; j<i ; j++){ if (i%j==0) goto skip; } pn++; skip:; } if(n==0 || n==1 ) { cout << 0 << endl; } else { cout << pn << endl; } cn++; if(cn>=30) break; } return 0; }
a.cc: In function 'int main()': a.cc:4:15: error: 'cin' was not declared in this scope; did you mean 'cn'? 4 | while(cin>>n){ | ^~~ | cn a.cc:14:25: error: 'cout' was not declared in this scope 14 | cout << 0 << endl; | ^~~~ a.cc:14:38: error: 'endl' was not declared in this scope 14 | cout << 0 << endl; | ^~~~ a.cc:16:25: error: 'cout' was not declared in this scope 16 | cout << pn << endl; | ^~~~ a.cc:16:39: error: 'endl' was not declared in this scope 16 | cout << pn << endl; | ^~~~
s308931754
p00009
C++
#include <math.h> #include <iostream> #include <ios> #include <iomanip> #include <algorithm> #include <functional> #include <string> #define YES "YES" #define NO "NO" #define space ' ' using namespace std; void func(); int main(void) { func(); return 0; } #define MAXIMUM 1000000 bool table[MAXIMUM]; int cnt[MAXIMUM]; #define not true #define prime false void func() { table[0] = not; table[1] = not; for (int i = 2; i < MAXIMUM; i++) { if (table[i] == prime) { for (int j = i * 2; j < MAXIMUM; j += i) { table[j] = not; } } } for (int i = 1; i < MAXIMUM; i++) { if (table[i] == prime) { cnt[i] = cnt[i - 1] + 1; } else { cnt[i] = cnt[i - 1]; } } int n; while (cin >> n, !cin.eof()) { cout << cnt[n] << endl; } }
a.cc:29:9: error: "not" cannot be used as a macro name as it is an operator in C++ 29 | #define not true | ^~~ a.cc: In function 'void func()': a.cc:33:23: error: expected primary-expression before ';' token 33 | table[0] = not; | ^ a.cc:34:23: error: expected primary-expression before ';' token 34 | table[1] = not; | ^ a.cc:41:47: error: expected primary-expression before ';' token 41 | table[j] = not; | ^
s971046589
p00009
C++
#include <math.h> #include <iostream> #include <ios> #include <iomanip> #include <algorithm> #include <functional> #include <string> #define YES "YES" #define NO "NO" #define space ' ' #define not true #define prime false using namespace std; void init(); void func(); int main(void) { func(); return 0; } #define MAXIMUM 1000000 bool table[MAXIMUM]; int cnt[MAXIMUM]; #define not true #define prime false void init() { table[0] = not; table[1] = not; for (int i = 2; i < MAXIMUM; i++) { if (table[i] == prime) { for (int j = i * 2; j < MAXIMUM; j += i) { table[j] = not; } } } for (int i = 1; i < MAXIMUM; i++) { if (table[i] == prime) { cnt[i] = cnt[i - 1] + 1; } else { cnt[i] = cnt[i - 1]; } } } void func() { int n; init(); while (cin >> n, !cin.eof()) { cout << cnt[n] << endl; } }
a.cc:12:9: error: "not" cannot be used as a macro name as it is an operator in C++ 12 | #define not true | ^~~ a.cc:32:9: error: "not" cannot be used as a macro name as it is an operator in C++ 32 | #define not true | ^~~ a.cc: In function 'void init()': a.cc:37:31: error: expected primary-expression before ';' token 37 | table[0] = not; | ^ a.cc:38:23: error: expected primary-expression before ';' token 38 | table[1] = not; | ^ a.cc:45:47: error: expected primary-expression before ';' token 45 | table[j] = not; | ^
s746520706
p00009
C++
#include <math.h> #include <iostream> #include <ios> #include <iomanip> #include <algorithm> #include <functional> #include <string> #define YES "YES" #define NO "NO" #define space ' ' using namespace std; void init(); void func(); int main(void) { func(); return 0; } #define MAXIMUM 1000000 bool table[MAXIMUM]; int cnt[MAXIMUM]; bool not = true; bool prime = false; void init() { table[0] = not; table[1] = not; for (int i = 2; i < MAXIMUM; i++) { if (table[i] == prime) { for (int j = i * 2; j < MAXIMUM; j += i) { table[j] = not; } } } for (int i = 1; i < MAXIMUM; i++) { if (table[i] == prime) { cnt[i] = cnt[i - 1] + 1; } else { cnt[i] = cnt[i - 1]; } } } void func() { int n; init(); while (cin >> n, !cin.eof()) { cout << cnt[n] << endl; } }
a.cc:30:6: error: expected unqualified-id before 'not' token 30 | bool not = true; | ^~~ a.cc: In function 'void init()': a.cc:35:31: error: expected primary-expression before ';' token 35 | table[0] = not; | ^ a.cc:36:23: error: expected primary-expression before ';' token 36 | table[1] = not; | ^ a.cc:43:47: error: expected primary-expression before ';' token 43 | table[j] = not; | ^
s502416888
p00009
C++
import java.util.Scanner; class Main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); while(sc.hasNextInt()){ int n=sc.nextInt(); int prime=0; if(n>=2){ prime+=1; if(n>2){ for(int i=3;i<=n;i++){ if(prime_number(i)){ prime++; } } } } } System.out.println(prime); } public static boolean prime_number(int x){ for(int i=2;i<x;i++){ int amari=x%i; if(amari==0){ return false; } } return true; } }
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:4:7: error: expected ':' before 'static' 4 | public static void main(String[] args){ | ^~~~~~~ | : a.cc:4:25: error: 'String' has not been declared 4 | public static void main(String[] args){ | ^~~~~~ a.cc:4:34: error: expected ',' or '...' before 'args' 4 | public static void main(String[] args){ | ^~~~ a.cc:22:7: error: expected ':' before 'static' 22 | public static boolean prime_number(int x){ | ^~~~~~~ | : a.cc:22:15: error: 'boolean' does not name a type; did you mean 'bool'? 22 | public static boolean prime_number(int x){ | ^~~~~~~ | bool a.cc:31:2: error: expected ';' after class definition 31 | } | ^ | ; a.cc: In static member function 'static void Main::main(int*)': a.cc:5:1: error: 'Scanner' was not declared in this scope 5 | Scanner sc=new Scanner(System.in); | ^~~~~~~ a.cc:6:7: error: 'sc' was not declared in this scope 6 | while(sc.hasNextInt()){ | ^~ a.cc:13:4: error: 'prime_number' was not declared in this scope 13 | if(prime_number(i)){ | ^~~~~~~~~~~~ a.cc:20:1: error: 'System' was not declared in this scope 20 | System.out.println(prime); | ^~~~~~ a.cc:20:20: error: 'prime' was not declared in this scope 20 | System.out.println(prime); | ^~~~~
s016911023
p00009
C++
#include<iostream> #define N 999999 #define FOR(i,a,b) for( int i = ( a ); i < ( b ); i++ ) #define WHILE(n) while( std::cin >> n ) int p[(N+1)/2];int m[N+1];int mk();int main(){int n;p[0]=2;m[1]=0;m[2]=1;mk();WHILE(n){cout<<m[n]<<i'\n';}return 0;}int mk(){int i,j,e=1;REP(i,3,N_MAX){for(j=0;p[j]*p[j]<=i;j++){if(i%p[j]==0){goto tag;}}p[e]=i;e++;tag:m[i]=e;}}
a.cc: In function 'int main()': a.cc:5:88: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 5 | int p[(N+1)/2];int m[N+1];int mk();int main(){int n;p[0]=2;m[1]=0;m[2]=1;mk();WHILE(n){cout<<m[n]<<i'\n';}return 0;}int mk(){int i,j,e=1;REP(i,3,N_MAX){for(j=0;p[j]*p[j]<=i;j++){if(i%p[j]==0){goto tag;}}p[e]=i;e++;tag:m[i]=e;}} | ^~~~ | std::cout In file included from a.cc:1: /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ a.cc:5:100: error: 'i' was not declared in this scope 5 | int p[(N+1)/2];int m[N+1];int mk();int main(){int n;p[0]=2;m[1]=0;m[2]=1;mk();WHILE(n){cout<<m[n]<<i'\n';}return 0;}int mk(){int i,j,e=1;REP(i,3,N_MAX){for(j=0;p[j]*p[j]<=i;j++){if(i%p[j]==0){goto tag;}}p[e]=i;e++;tag:m[i]=e;}} | ^ a.cc: In function 'int mk()': a.cc:5:146: error: 'N_MAX' was not declared in this scope; did you mean 'TMP_MAX'? 5 | int p[(N+1)/2];int m[N+1];int mk();int main(){int n;p[0]=2;m[1]=0;m[2]=1;mk();WHILE(n){cout<<m[n]<<i'\n';}return 0;}int mk(){int i,j,e=1;REP(i,3,N_MAX){for(j=0;p[j]*p[j]<=i;j++){if(i%p[j]==0){goto tag;}}p[e]=i;e++;tag:m[i]=e;}} | ^~~~~ | TMP_MAX a.cc:5:138: error: 'REP' was not declared in this scope 5 | int p[(N+1)/2];int m[N+1];int mk();int main(){int n;p[0]=2;m[1]=0;m[2]=1;mk();WHILE(n){cout<<m[n]<<i'\n';}return 0;}int mk(){int i,j,e=1;REP(i,3,N_MAX){for(j=0;p[j]*p[j]<=i;j++){if(i%p[j]==0){goto tag;}}p[e]=i;e++;tag:m[i]=e;}} | ^~~ a.cc:5:227: warning: no return statement in function returning non-void [-Wreturn-type] 5 | int p[(N+1)/2];int m[N+1];int mk();int main(){int n;p[0]=2;m[1]=0;m[2]=1;mk();WHILE(n){cout<<m[n]<<i'\n';}return 0;}int mk(){int i,j,e=1;REP(i,3,N_MAX){for(j=0;p[j]*p[j]<=i;j++){if(i%p[j]==0){goto tag;}}p[e]=i;e++;tag:m[i]=e;}} | ^
s785013640
p00009
C++
#pragma warning (disable:4996) #include<iostream> #include<cstdio> #include<queue> #include<cstring> #include<string> #include<cmath> #include<algorithm> #define MAX 1000000 using namespace std; int amount[MAX]; int vis[MAX]; int prime[MAX]; int main(){ memset(vis, 0, sizeof(vis)); memset(prime, 0, sizeof(prime)); prime[0] = prime[1] = 0; int n; cin >> n; for (int i = 2; i<=n; i++){ if (!vis[i]){ prime[i] = 1; for (int j = i+i; j<=n; j += i){ vis[j] = 1; prime[j] = 0; } } int sum = 0; for (int i = 2; i <= n; i++){ if (prime[i]){ sum++; } } cout << sum << endl; return 0; }
a.cc: In function 'int main()': a.cc:38:2: error: expected '}' at end of input 38 | } | ^ a.cc:14:11: note: to match this '{' 14 | int main(){ | ^
s004108050
p00009
C++
#pragma warning (disable:4996) #include<iostream> #include<cstdio> #include<queue> #include<cstring> #include<string> #include<cmath> #include<algorithm> #define MAX 1000000 using namespace std; int amount[MAX]; int vis[MAX]; int prime[MAX]; int main(){ memset(vis, 0, sizeof(vis)); memset(prime, 0, sizeof(prime)); prime[0] = prime[1] = 0; int n; cin >> n; for (int i = 2; i<=n; i++){ if (!vis[i]){ prime[i] = 1; for (int j = i+i; j<=n; j += i){ vis[j] = 1; prime[j] = 0; } } int sum = 0; for (int i = 2; i <= n; i++){ if (prime[i]){ sum++; } } cout << sum << endl; return 0; }
a.cc: In function 'int main()': a.cc:38:2: error: expected '}' at end of input 38 | } | ^ a.cc:14:11: note: to match this '{' 14 | int main(){ | ^
s581006927
p00009
C++
qa
a.cc:1:1: error: 'qa' does not name a type 1 | qa | ^~
s213081319
p00009
C++
#include <iostream> #include <cmath> #include <algorithm> template<int N> class primes { public: constexpr static auto NN = static_cast<int>(std::sqrt(N)); public: constexpr primes() { for( int i=2; i<N; ++i ) not_primes[i] = false; for( int i=2; i<NN; ++i ) { if ( not_primes[i] ) continue; for( int j=i*i; j<N; j+=i ) { not_primes[j] = true; } } } auto count(int i) const { return std::count(std::begin(not_primes), std::begin(not_primes) + i + 1, false); } private: bool not_primes[N] = {true, true}; }; int main() { constexpr auto N = 999999+1; constexpr auto ps = primes<N>{}; int i; while( std::cin >> i ) { std::cout << ps.count(i) << std::endl; } }
a.cc: In function 'int main()': a.cc:38:35: in 'constexpr' expansion of 'primes<1000000>()' a.cc:14:9: error: 'constexpr' loop iteration count exceeds limit of 262144 (use '-fconstexpr-loop-limit=' to increase the limit) 14 | for( int i=2; i<N; ++i ) | ^~~
s302296748
p00009
C++
#include<iostream> #include<vector> #include<algorithm> using namespace std; int main() { vector<int> prime_num{ 2, 3 }; int n; while (cin >> n){ int result; if (n <= 1) { result = 0; } else if (n == 2){ result = 1; } else if (n < prime_num.back()){ result = count_if(prime_num.begin(), prime_num.end(), [n](int a){return a <= n; }); } else { for (int i = prime_num.back() + 2; i <= n; i += 2) { if (all_of(prime_num.begin(), prime_num.end(), [i](int a){return (i % a) != 0; })) { prime_num.push_back(i); } } result = prime_num.size(); } cout << result << endl;javascript:void(0) } return 0; }
a.cc: In function 'int main()': a.cc:33:58: error: expected ';' before '}' token 33 | cout << result << endl;javascript:void(0) | ^ | ; 34 | } | ~
s109075066
p00009
C++
#include <stdio.h> #include <stdlib.h> #include <string.h> int prime(int n) { int k; for(k = 2; k * k <= n; k++) { if(n % k == 0) return 0; } return 1; } int cntPrime(int n) { int cnt = 0, i, k; for(i = 2; i <= n; i++) { cnt += prime(i); } return cnt; } int main() { int a; int arg[1024] = { 0 }; int cnt = 0; while(scanf("%d", &a) != EOF) { printf("%d\n", cntPrime(a)); } int i; for(i = 0; i < cnt; i++) { } } ~ ~ ~
a.cc:33:1: error: expected class-name before '~' token 33 | ~ | ^
s962774714
p00009
C++
#include <stdio.h> #include <stdlib.h> #include <string.h> int prime(int n) { int k; for(k = 2; k * k <= n; k++) { if(n % k == 0) return 0; } return 1; } int cntPrime(int n) { int cnt = 0, i, k; for(i = 2; i <= n; i++) { cnt += prime(i); } return cnt; } int main() { int a; int arg[1024] = { 0 }; int cnt = 0; while(scanf("%d", &a) != EOF) { printf("%d\n", cntPrime(a)); } int i; for(i = 0; i < cnt; i++) { } } ~
a.cc:32:2: error: expected class-name at end of input 32 | ~ | ^
s184056988
p00009
C++
#include <cmath> #include <iostream> using namespace std; bool isprime(int n) { for (int i = 2; i <= sqrt(n); i++) { if (n % i == 0) return false; } return true; } int main() { int N[31]; int C[31]; memset(N, 0, sizeof(N)); for (int i = 0; i < 3; i++) { for (int j = 2; j <= N[i]; j++) { if (isprime(j) == true) { C[i] += 1; } } } for (int i = 0; i < 31; i++) { cout << C[i] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:19:20: error: 'memset' was not declared in this scope 19 | int C[31]; memset(N, 0, sizeof(N)); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include <iostream> +++ |+#include <cstring> 3 |
s368949239
p00009
C++
#include<iostream> #include<cstdio> #include<vector> using namespace std; vector<int>soe(int n); int main(void) { int num; while(cin >> num){ vector<int>sosu(num); sosu = soe(num); int a_size = sosu.size(); cout << a_size << endl; /*for(int i = 1; i < num; i++){ cout << sosu[i] <<endl; }*/ } return 0; } vector<int>soe(int n){ vector<int>hyo(n); for(int i = 2; i < n; i++){ //??\??? hyo[i] = i; } for(int i = 2; i*i < n; i++){ //???????????§??°????????? if(hyo[i]) for(int j = i*i; j < n; j += i){ hyo.erase(remove(hyo.begin(), hyo.end(), j), hyo.end()); } } hyo.erase(remove(hyo.begin(), hyo.end(), 0), hyo.end()); hyo.erase(remove(hyo.begin(), hyo.end(), 1), hyo.end()); return hyo; }
a.cc: In function 'std::vector<int> soe(int)': a.cc:32:51: error: cannot convert 'std::vector<int>::iterator' to 'const char*' 32 | hyo.erase(remove(hyo.begin(), hyo.end(), j), hyo.end()); | ~~~~~~~~~^~ | | | std::vector<int>::iterator In file included from /usr/include/c++/14/cstdio:42, from /usr/include/c++/14/ext/string_conversions.h:45, from /usr/include/c++/14/bits/basic_string.h:4154, 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/stdio.h:158:32: note: initializing argument 1 of 'int remove(const char*)' 158 | extern int remove (const char *__filename) __THROW; | ~~~~~~~~~~~~^~~~~~~~~~ a.cc:35:35: error: cannot convert 'std::vector<int>::iterator' to 'const char*' 35 | hyo.erase(remove(hyo.begin(), hyo.end(), 0), hyo.end()); | ~~~~~~~~~^~ | | | std::vector<int>::iterator /usr/include/stdio.h:158:32: note: initializing argument 1 of 'int remove(const char*)' 158 | extern int remove (const char *__filename) __THROW; | ~~~~~~~~~~~~^~~~~~~~~~ a.cc:36:35: error: cannot convert 'std::vector<int>::iterator' to 'const char*' 36 | hyo.erase(remove(hyo.begin(), hyo.end(), 1), hyo.end()); | ~~~~~~~~~^~ | | | std::vector<int>::iterator /usr/include/stdio.h:158:32: note: initializing argument 1 of 'int remove(const char*)' 158 | extern int remove (const char *__filename) __THROW; | ~~~~~~~~~~~~^~~~~~~~~~
s064708337
p00009
C++
#include <stdio.h> #define MAX_SIZE(1000001) int prime[MAX_SIZE]; int main() { int n, i, j; for (i = 0; i < MAX_SIZE; i++){ prime[i] = 1; } prime[0] = prime[1] = 0; for (i = 2; i * i < MAX_SIZE; i++){ if (prime[i] == 1){ for (j = i * i; j < MAX_SIZE; j += i){ prime[j] = 0; } } } for (i = 1; i < MAX_SIZE - 1; i++){ prime[i + 1] += prime[i]; } while (scanf("%d", &n) != EOF){ printf("%d\n", prime[n]); } return 0; }
a.cc:3:18: error: expected parameter name, found "1000001" 3 | #define MAX_SIZE(1000001) | ^~~~~~~ a.cc:5:11: error: 'MAX_SIZE' was not declared in this scope 5 | int prime[MAX_SIZE]; | ^~~~~~~~ a.cc: In function 'int main()': a.cc:11:17: error: 'MAX_SIZE' was not declared in this scope 11 | for (i = 0; i < MAX_SIZE; i++){ | ^~~~~~~~ a.cc:12:1: error: 'prime' was not declared in this scope 12 | prime[i] = 1; | ^~~~~ a.cc:15:1: error: 'prime' was not declared in this scope 15 | prime[0] = prime[1] = 0; | ^~~~~ a.cc:17:21: error: 'MAX_SIZE' was not declared in this scope 17 | for (i = 2; i * i < MAX_SIZE; i++){ | ^~~~~~~~ a.cc:25:17: error: 'MAX_SIZE' was not declared in this scope 25 | for (i = 1; i < MAX_SIZE - 1; i++){ | ^~~~~~~~
s068561045
p00009
C++
import java.util.Scanner; public class Main { //?¨???????????????? public int kazu(int num){ //?´???°??????????????????????????°???????????? int count = 0; //?´???°????????????????????? boolean result; for(int i = 2; i < num; i++){ //?´???°??§????????¨????????????????????? result = true; for(int j = 2; j < i; j++){ if(i % j == 0){ //?´???°???????????´????´???°??§?????? result = false; break; } } //??????????????§?????????????´???°??¨?????????????????? if(result)count++; } return count; } public static void main(String[] args){ Scanner sc = new Scanner (System.in); //?????????????????°???????´????????????? Main2 sosu = new Main2(); int num = sc.nextInt(); while(num < 100000){ System.out.println(sosu.kazu(num)); num = sc.nextInt(); } } }
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:3:1: error: expected unqualified-id before 'public' 3 | public class Main { | ^~~~~~
s951316024
p00009
C++
public static void main(String[] args) { int n = 35; int a,b,c,d; int cnt = 0; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if(i+j > n) break; for (int k = 0; k < 10; k++) { if(i+ j + k > n) break; for (int l = 0; l < 10; l++) { if(i+j+k+l > n) break; if(i+j+k+l == n) { cnt++; System.out.println(i + " " + j + " " + k + " " + l); } } } } } }
a.cc:1:9: error: expected unqualified-id before 'public' 1 | public static void main(String[] args) { | ^~~~~~
s028395637
p00009
C++
#include<iostream> const int MAX_N=1000000; using namespace std; bool value[MAX_N]; int main(){ int n; while(cin>>n){ int count=0; for(int i=1;i<=n;++i){ value[i]=true; } for(int i=2;i<=n;++i){ if(value[i]){ for(int j=2;j<=n/i;++j){ value[j*i]=false; } } for(int i=2;i<=n;++i){ if(value[i]) ++count; } cout<<count<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:25:2: error: expected '}' at end of input 25 | } | ^ a.cc:5:11: note: to match this '{' 5 | int main(){ | ^
s795251863
p00009
C++
#include<iostream> #define Max 1000000 bool prime[Max]; void IsPrime(){ prime[0]=prime[1]=0;prime[2]=1; for(int i=3;i<Max;i++) prime[i]=i%2==0?0:1; int t=(int)sqrt(Max*1.0); for(int i=3;i<=t;i++) if(prime[i]) for(int j=i*i;j<Max;j+=2*i)//?化 prime[j]=0; } int main(){ int n; IsPrime(); int time=0; while((time<=30)&&(std::cin>>n)){ int count=0; for(int i=2;i<=n;++i){ if(prime[i]) ++count; } std::cout<<count<<std::endl; time++; } }
a.cc: In function 'void IsPrime()': a.cc:9:17: error: 'sqrt' was not declared in this scope 9 | int t=(int)sqrt(Max*1.0); | ^~~~
s847144475
p00009
C++
#include<iostream> #include<cstdio> #include <cstring> using namespace std; int main() { int n; while(scanf("%d",&n)!=EOF) { int count=0; bool a[1000001]; memset() for(int i=2;i*i<=n;i++) { if(a[i]==false) { for(int j=i;j<=n;j+=i) { if(j==i) continue; a[j]=true; } } } for(int k=2;k<=n;k++) { if(!a[k]) count+=1; } cout<<count<<endl; } }
a.cc: In function 'int main()': a.cc:12:23: error: too few arguments to function 'void* memset(void*, int, size_t)' 12 | memset() | ~~~~~~^~ In file included from /usr/include/c++/14/cstring:43, from a.cc:3: /usr/include/string.h:61:14: note: declared here 61 | extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1)); | ^~~~~~ a.cc:13:29: error: 'i' was not declared in this scope 13 | for(int i=2;i*i<=n;i++) | ^
s057295013
p00009
C++
#include <iostream> #include <cstring> using namespace std; #define maxn 1000000 int isprime(int n) { int p = 0; memset(prime,true,sizeof(prime)); prime[0] = prime[1] = false; for(int i=2;i<=n;i++) { if(prime[i]) { for(int j=2*i;j<=n;j+=i) prime[j] = false; p++; } } return p; } int main() { int n; while(cin>>n) { bool prime[maxn]; cout<<isprime(n)<<endl; } return 0; }
a.cc: In function 'int isprime(int)': a.cc:10:10: error: 'prime' was not declared in this scope 10 | memset(prime,true,sizeof(prime)); | ^~~~~
s528088455
p00009
C++
#include<iostream> #include<string> using namespace std; const int MAX_N=10000000; bool data[10000000]; int sum[10000000]; void solve() { for (int i = 2; 2 * i < MAX_N;i++) if (data[i]) for (int j = 2 * i; j < MAX_N; j = j + i) data[j] = false; data[0] = data[1] = false; for (int i = 0; i < MAX_N; i++) sum[i + 1] = sum[i] + data[i + 1]; } int main() { memset(data, true, sizeof(data)); int n = 0; solve(); while (cin >> n){ cout << sum[n] << endl; } }
a.cc: In function 'void solve()': a.cc:10:13: error: reference to 'data' is ambiguous 10 | if (data[i]) | ^~~~ In file included from /usr/include/c++/14/string:53, 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/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:5:6: note: 'bool data [10000000]' 5 | bool data[10000000]; | ^~~~ a.cc:12:17: error: reference to 'data' is ambiguous 12 | data[j] = false; | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:5:6: note: 'bool data [10000000]' 5 | bool data[10000000]; | ^~~~ a.cc:14:9: error: reference to 'data' is ambiguous 14 | data[0] = data[1] = false; | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:5:6: note: 'bool data [10000000]' 5 | bool data[10000000]; | ^~~~ a.cc:14:19: error: reference to 'data' is ambiguous 14 | data[0] = data[1] = false; | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:5:6: note: 'bool data [10000000]' 5 | bool data[10000000]; | ^~~~ a.cc:17:39: error: reference to 'data' is ambiguous 17 | sum[i + 1] = sum[i] + data[i + 1]; | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:5:6: note: 'bool data [10000000]' 5 | bool data[10000000]; | ^~~~ a.cc: In function 'int main()': a.cc:22:16: error: reference to 'data' is ambiguous 22 | memset(data, true, sizeof(data)); | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:5:6: note: 'bool data [10000000]' 5 | bool data[10000000]; | ^~~~ a.cc:22:35: error: reference to 'data' is ambiguous 22 | memset(data, true, sizeof(data)); | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:5:6: note: 'bool data [10000000]' 5 | bool data[10000000]; | ^~~~ a.cc:22:9: error: 'memset' was not declared in this scope 22 | memset(data, true, sizeof(data)); | ^~~~~~ a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include<iostream> +++ |+#include <cstring> 2 | #include<string>
s834558140
p00009
C++
#include <utility> #include <iostream> using namespace std; #define MAX_N 99999 #define MAX_D 30 bool prime_check(int n, int k = 2) { if (n < k * k) { return true; } if (n % k == 0) { return false; } return prime_check(n, k + 1); } int main() { int n; bool isprime[MAX_N + 1]; for (int i = 2; i < MAX_N + 1; i++) { isprime[i] = prime_check(i); } while (cin >> n) { cout << count(isprime + 2, isprime + n + 1, true) << endl; } return 0; }
a.cc: In function 'int main()': a.cc:31:25: error: 'count' was not declared in this scope 31 | cout << count(isprime + 2, isprime + n + 1, true) << endl; | ^~~~~
s085644853
p00009
C++
#include <utility> #include <iostream> using namespace std; #define MAX_N 99999 #define MAX_D 30 bool prime_check(int n, int k = 2) { if (n < k * k) { return true; } if (n % k == 0) { return false; } return prime_check(n, k + 1); } int main() { int n; bool isprime[MAX_N + 1]; for (int i = 2; i < MAX_N + 1; i++) { isprime[i] = prime_check(i); } while (cin >> n) { cout << count(isprime + 2, isprime + n + 1, true) << endl; } return 0; }
a.cc: In function 'int main()': a.cc:31:25: error: 'count' was not declared in this scope 31 | cout << count(isprime + 2, isprime + n + 1, true) << endl; | ^~~~~