submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s944361279
p00009
C++
#include <iostream> #include <xutility> 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:2:10: fatal error: xutility: No such file or directory 2 | #include <xutility> | ^~~~~~~~~~ compilation terminated.
s896045442
p00009
C++
#include<iostream> using namespace std; int sushu[1000010]; int n; bool isPrime(int a){ if (sushu[a] != -1){ return sushu[a] == 0 ? false : true; } int i; for (i = 2; i < a; ++i){ if (a%i == 0){ sushu[a] = 0; return false; } } sushu[a] = 1; return true; } int main() { memset(sushu, -1, sizeof(sushu)); while (cin >> n){ for (int i = 2; i <= n; ++i){ if (isPrime(i)) cout << i << endl; } } return 0; }
a.cc: In function 'int main()': a.cc:22:9: error: 'memset' was not declared in this scope 22 | memset(sushu, -1, sizeof(sushu)); | ^~~~~~ 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 | using namespace std;
s712850996
p00009
C++
#include <Stdio.h> int main() { int n,i,j,flag=0,cnt,h,k; while(scanf("%d",&n) !=EOF) { if(n==2) printf("1"); else if(n==3) printf("2"); else { cnt=2; h=n/2; for(k=4; k<=n; k++) { for(j=2; j<=h; j+=2) { if(k%j==0) { flag=1; break; } } if(flag==0) cnt++; else flag=0; } printf("%d",cnt-1); } } return 0; }
a.cc:1:10: fatal error: Stdio.h: No such file or directory 1 | #include <Stdio.h> | ^~~~~~~~~ compilation terminated.
s421101115
p00009
C++
LIMIT = 10000000 isPrime = [True for _ in range(LIMIT)] isPrime[0] = isPrime[1] = False for i in range(2, int(LIMIT ** 0.5)+1): if isPrime[i]: for j in range(i * i, LIMIT, i): isPrime[j] = False try: while True: n = int(input()) count = 0 for i in range(n+1): if isPrime[i]: count += 1 print(count) except EOFError: pass
a.cc:1:1: error: 'LIMIT' does not name a type 1 | LIMIT = 10000000 | ^~~~~
s730963649
p00009
C++
#include <stdio.h> #include <math.h> #include <stdlib.h> #define N 999999L bool num[N]; void furui(){ long int i; int divide; int rt = (int) sqrt(N); for(i = 0L; i < N; i++){ num[i] = true; } num[0] = false; num[1] = false; for(divide = 2; divide <= rt; divide++){ if(num[divide] == false) continue; for( i = divide; i < N; i+= divide){ num[i] = false; } num[divide] = true; } } int main(void){ int c, i, j; long int k; char buf[7]; long int n; long int count; furui(); for(j = 0; j < 30; j++){ for(i = 0; ;i++){ c = getchar(); if(c == EOF || c == '\n'){ buf[i] = '\0'; break; } buf[i] = c; } n = atol(buf); count = 0L; for(k = 1L; k <= n; k++){ if(num[k] == 1) count++; } std::cout << count << '\n'; if(c == EOF) break; } return 0; }
a.cc: In function 'int main()': a.cc:48:10: error: 'cout' is not a member of 'std' 48 | std::cout << count << '\n'; | ^~~~ a.cc:4:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 3 | #include <stdlib.h> +++ |+#include <iostream> 4 | #define N 999999L
s329723381
p00009
C++
#include <stdio.h> #include <math.h> #include <stdlib.h> #define N 999999L bool num[N]; void furui(){ long int i; int divide; int rt = (int) sqrt(N); for(i = 0L; i < N; i++){ num[i] = true; } num[0] = false; num[1] = false; for(divide = 2; divide <= rt; divide++){ if(num[divide] == false) continue; for( i = divide; i < N; i+= divide){ num[i] = false; } num[divide] = true; } } int main(void){ int c, i, j; long int k; char buf[7]; long int n; long int count; furui(); for(j = 0; j < 30; j++){ for(i = 0; ;i++){ c = getchar(); if(c == EOF || c == '\n'){ buf[i] = '\0'; break; } buf[i] = c; } n = atol(buf); count = 0L; for(k = 1L; k <= n; k++){ if(num[k] == 1) count++; } std::cout << count << "\n"; if(c == EOF) break; } return 0; }
a.cc: In function 'int main()': a.cc:48:10: error: 'cout' is not a member of 'std' 48 | std::cout << count << "\n"; | ^~~~ a.cc:4:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 3 | #include <stdlib.h> +++ |+#include <iostream> 4 | #define N 999999L
s534014714
p00009
C++
// aoj.cpp : コンソール アプリケーションのエントリ ポイントを定義します。 // #include "stdafx.h" #include <stdio.h> #include <math.h> #include <stdlib.h> #include <iostream> #define N 1000000L bool num[N]; void furui() { long int i; int divide; int rt = 1000; for (i = 0L; i < N; i++) { num[i] = true; } num[0] = false; num[1] = false; for (divide = 2; divide <= rt; divide++) { if (num[divide] == false) continue; for (i = (long int)divide; i < N; i += divide) { num[i] = false; } num[divide] = true; } } int main(void) { int c, i, j; long int k; char buf[7]; long int n; long int count; furui(); for (j = 0; j < 30; j++) { for (i = 0; ; i++) { c = getchar(); if (c == EOF || c == '\n') { buf[i] = '\0'; break; } buf[i] = c; } n = atol(buf); count = 0L; for (k = 1L; k <= n; k++) { if (num[k] == true) count++; } std::cout << count << std::endl; if (c == EOF) break; } return 0; }
a.cc:4:10: fatal error: stdafx.h: No such file or directory 4 | #include "stdafx.h" | ^~~~~~~~~~ compilation terminated.
s954379962
p00009
C++
#include <iostream> #include <string> #include <algorithm> using namespace std; // cin >> // cin << bool isPrime(int x){ if(x==2) return true; if(x<2||x%2==0) return false; int i=3; while(i<=sqrt(x)){ if (x%i==0)return false; i= i+2; } return true; } int main(){ int in[30]={}; int out=0; for(int i=0;i<30;i++) cin >>in[i]; for(int i=0;i<30;i++){ if(in[i]==0){ break; }else{ out=0; for(int j=0;j<in[i]+1;j++){ if(isPrime(j)==true){ out++; } } cout <<out<<endl; } } return 0; }
a.cc: In function 'bool isPrime(int)': a.cc:14:18: error: 'sqrt' was not declared in this scope 14 | while(i<=sqrt(x)){ | ^~~~
s240432524
p00009
C++
#include <iostream> #include <cmath> #define MAX_NUM (1000000) static int getPrimeNum(int maxVal); int main(void) { int n; while (std::cin >> n) { std::cout << getPrimeNum(n) << std::endl; } return 0; } static int getPrimeNum(int maxVal) { static int searchList[MAX_NUM] = {0}; static int primeList[MAX_NUM] = {0}; memset(searchList, 0, sizeof(int) * MAX_NUM); memset(primeList, 0, sizeof(int) * MAX_NUM); double sqMaxVal = sqrt((double)maxVal) + 1; for (int i = 2; i <= sqMaxVal; i++) { if (searchList[i] == 0) { searchList[i] = 1; primeList[i] = 1; for (int j = i + 1; j <= maxVal; j++) { if (j % i == 0) { searchList[j] = 1; } } } } for (int i = 2; i <= maxVal; i++) { if (searchList[i] == 0) { primeList[i] = 1; } } int count = 0; for (int i = 2; i <= maxVal; i++) { if (primeList[i] == 1) { count++; } } return count; }
a.cc: In function 'int getPrimeNum(int)': a.cc:24:3: error: 'memset' was not declared in this scope 24 | memset(searchList, 0, sizeof(int) * MAX_NUM); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include <cmath> +++ |+#include <cstring> 3 |
s270679573
p00009
C++
import java.util.Scanner; public class Main{ public static void main(String[] args){ while(true){ Scanner sc=new Scanner(System.in); int INF=1000; int cnt=0; int n=sc.nextInt(); int[] prime=new int[n+1]; for(int i=0;i<=n;i++){ prime[i]=INF; } for(int i=2;i<=n;i++){ if(prime[i]==INF&&n%i==0){ prime[i]=0; cnt++; for(int j=2;j*i<=n;j++){ prime[j*i]=1; } } } sc.close(); System.out.println(cnt); } } }
a.cc:2:1: error: 'import' does not name a type 2 | import java.util.Scanner; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: expected unqualified-id before 'public' 3 | public class Main{ | ^~~~~~
s686375443
p00009
C++
import java.util.Scanner; public class Main{ public static void main(String[] args){ while(true){ Scanner sc=new Scanner(System.in); int INF=1000; int cnt=0; int n=sc.nextInt(); int[] prime=new int[n+1]; for(int i=0;i<=n;i++){ prime[i]=INF; } for(int i=2;i<=n;i++){ if(prime[i]==INF&&n%i==0){ prime[i]=0; cnt++; for(int j=2;j*i<=n;j++){ prime[j*i]=1; } } } sc.close(); System.out.println(cnt); } } }
a.cc:2:1: error: 'import' does not name a type 2 | import java.util.Scanner; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: expected unqualified-id before 'public' 3 | public class Main{ | ^~~~~~
s443782629
p00009
C++
#include <iostream> #include <cstdio> #include <vector> using namespace std; const int MAX_N = int(1e6); ?? int main(){ ?? ????int n, i, j, maxin = 2; ????bool jud; ????vector <int> vec; ????for(i = 2;i <= MAX_N; i++){ ????????????????jud = 0; ????????????????for(j = 0;?? j < vec.size() ; j++){ ????????????????????if(vec[ j ] * vec[ j ] > i) break; ????????????????????if( !( i % vec[ j ] ) ){ ????????????????????????jud = 1; ????????????????????????break; ????????????????????} ????????????????} ????????????????if(!jud) ????????????????????vec.push_back( i ); ????????????} ????while(cin >> n){ ????????cout << upper_bound(vec.begin(), vec.end(), n) - vec.begin()???? <<endl; ????} }
a.cc:6:1: error: expected unqualified-id before '?' token 6 | ?? | ^
s895078253
p00009
C++
#include <iostream> #include <cstdio> #include <vector> using namespace std; const int MAX_N = int(1e6); int main(){ int n, i, j, maxin = 2; bool jud; vector <int> vec; for (i = 2; i <= MAX_N; i++){ jud = 0; for (j = 0; j < vec.size(); j++){ if (vec[j] * vec[j] > i) break; if (!(i % vec[j])){ jud = 1; break; } } if (!jud) vec.push_back(i); } while (cin >> n){ cout << upper_bound(vec.begin(), vec.end(), n) - vec.begin() << endl; } }
a.cc: In function 'int main()': a.cc:25:17: error: 'upper_bound' was not declared in this scope 25 | cout << upper_bound(vec.begin(), vec.end(), n) - vec.begin() << endl; | ^~~~~~~~~~~
s796208226
p00009
C++
#include <stdio.h> #define MN int main(void) { int n; int i, j; long LN = 1000001; int pn[1000001]; for (i = 0; i < LN; i++){ pn[i] = 1; } pn[0] = pn[1] = 0; for (i = 2; i * i < LN; i++){ if (pn[i] == 1){ for (j = i * i; j < LN; j += i){ pn[j] = 0; } } } for (i = 1; i < LN - 1; i++){ pn[i + 1] += pn[i]; } while (cin >> n){ cout << pn[n] << endl; } return (0); }
a.cc: In function 'int main()': a.cc:30:12: error: 'cin' was not declared in this scope 30 | while (cin >> n){ | ^~~ a.cc:31:9: error: 'cout' was not declared in this scope 31 | cout << pn[n] << endl; | ^~~~ a.cc:31:26: error: 'endl' was not declared in this scope 31 | cout << pn[n] << endl; | ^~~~
s896621795
p00009
C++
#include <iostream> using namespace std; int main() { int n; int count; while (1) { cin >> n; if (cin.fail()) break; bool *isPrime; isPrime = new bool[n + 1]; memset(isPrime, true, sizeof(bool) * (n + 1)); isPrime[0] = isPrime[1] = false; count = 0; for (int i = 2; i <= n; ++i) { for (int j = i + i; j <= n; j += i) { isPrime[j] = false; } } for (int i = 0; i <= n; ++i) { if (isPrime[i] == true) ++count; } cout << count << endl; delete[] isPrime; } return 0; }
a.cc: In function 'int main()': a.cc:16:17: error: 'memset' was not declared in this scope 16 | memset(isPrime, true, sizeof(bool) * (n + 1)); | ^~~~~~ 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 |
s002734917
p00009
C++
#include<iostream> #include<string> using namespace std; int main(){ int n,a[9]; a[0]=9592; a[1]=17984; a[2]=25997; a[3]=33860; a[4]=41538; a[5]=49098; a[6]=56543; a[7]=63951; a[8]=71274; while(cin>>n){ int count=0; int i=0; while(true){ if((i+1)*100000<=n) count=a[i]; else break; i++; } if(n<100000){ count=1; for(int j=3;j<=n;j++){ bool t=false; for(int k=2;k<1+(double)sqrt((double)j);k++){ if(j%k==0) t=true; } if(t==false) count++; } } else{ for(int j=(i)*100000+1;j<=n;j++){ bool t=false; for(int k=2;k<1+(double)sqrt((double)j);k++){ if(j%k==0) t=true; } if(t==false) count++; } } cout<<count<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:29:49: error: 'sqrt' was not declared in this scope 29 | for(int k=2;k<1+(double)sqrt((double)j);k++){ | ^~~~ a.cc:40:53: error: 'sqrt' was not declared in this scope 40 | for(int k=2;k<1+(double)sqrt((double)j);k++){ | ^~~~
s945010150
p00009
C++
#include <iostream> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { int n, count,k; while(cin >> n){ count = 1; k = 0; for(int i = 3; i <= n; i += 2){ for(int j = 3; j <= sqrt((double)i); j += 2) { if(i%j == 0){ k = 1; break; } } if(k == 0){ count++; } } cout << count << endl; } return 0; }
a.cc:5:22: error: '_TCHAR' has not been declared 5 | int _tmain(int argc, _TCHAR* argv[]) | ^~~~~~ a.cc: In function 'int _tmain(int, int**)': a.cc:14:45: error: 'sqrt' was not declared in this scope 14 | for(int j = 3; j <= sqrt((double)i); j += 2) | ^~~~
s121705112
p00009
C++
// PrimeNumber.cpp : ??????????????? ??¢????????±????????§????????¨????????? ????????????????????????????????? // #include "stdafx.h" #include <iostream> using namespace std; int main(int argc, char* argv[]) { int n, count,k; while(cin >> n){ count = 1; k = 0; for(int i = 3; i <= n; i += 2){ for(int j = 3; j <= sqrt((double)i); j += 2) { if(i%j == 0){ k = 1; break; } } if(k == 0){ count++; } } cout << count << endl; } return 0; }
a.cc:4:10: fatal error: stdafx.h: No such file or directory 4 | #include "stdafx.h" | ^~~~~~~~~~ compilation terminated.
s143109431
p00009
C++
#include <iostream> using namespace std; int main(int argc, char* argv[]) { int n, count,k; while(cin >> n){ count = 1; k = 0; for(int i = 3; i <= n; i += 2){ for(int j = 3; j <= sqrt((double)i); j += 2) { if(i%j == 0){ k = 1; break; } } if(k == 0){ count++; } } cout << count << endl; } return 0; }
a.cc: In function 'int main(int, char**)': a.cc:15:45: error: 'sqrt' was not declared in this scope 15 | for(int j = 3; j <= sqrt((double)i); j += 2) | ^~~~
s914699002
p00009
C++
#include <iostream> using namespace std; int main() { int n, count,k; while(cin >> n){ count = 1; k = 0; for(int i = 3; i <= n; i += 2){ for(int j = 3; j <= std::sqrt((double)i); j += 2) { if(i%j == 0){ k = 1; break; } } if(k == 0){ count++; } } cout << count << endl; } return 0; }
a.cc: In function 'int main()': a.cc:15:50: error: 'sqrt' is not a member of 'std' 15 | for(int j = 3; j <= std::sqrt((double)i); j += 2) | ^~~~
s771732780
p00009
C++
#include <iostream> #include <string> #include <stack> #include <math.h> #include <algorithm> #include <cstdlib> #include <ctime> #include <vector> using namespace std; int sieve(int n); int prime[1000000]; bool is_prime[1000000]; int main() { int p = 0; for (int i = 0; i <= 999999; i++) { is_prime[i] = true; } is_prime[0] = is_prime[1] = false; for (int i = 2; i <= 999999; i++) { if (is_prime[i]) { prime[p++] = i; for (int j = 2 * i; j <= 999999; j += i) { is_prime[j] = false; } } } int n; while (scanf_s("%d", &n) != EOF) { int i = 0; while (prime[i] <= n) { i++; } cout << i << endl; } }
a.cc: In function 'int main()': a.cc:32:16: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'? 32 | while (scanf_s("%d", &n) != EOF) { | ^~~~~~~ | scanf
s713396388
p00009
C++
#include <iostream> #include <string> #include <stack> #include <math.h> #include <algorithm> #include <cstdlib> #include <ctime> #include <vector> using namespace std; int sieve(int n); int prime[1000000]; bool is_prime[1000000]; int main() { int p = 0; for (int i = 0; i <= 999999; i++) { is_prime[i] = true; } is_prime[0] = is_prime[1] = false; for (int i = 2; i <= 999999; i++) { if (is_prime[i]) { prime[p++] = i; for (int j = 2 * i; j <= 999999; j += i) { is_prime[j] = false; } } } int n; while (scanf_s("%d", &n) != EOF) { int i = 0; while (prime[i] <= n) { i++; } cout << i << endl; } }
a.cc: In function 'int main()': a.cc:32:16: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'? 32 | while (scanf_s("%d", &n) != EOF) { | ^~~~~~~ | scanf
s934623581
p00009
C++
#include <iostream> #include <string> #include <stack> #include <math.h> #include <algorithm> #include <cstdlib> #include <ctime> #include <vector> using namespace std; int sieve(int n); int prime[1000000]; bool is_prime[1000000]; int main() { int p = 0; for (int i = 0; i <= 999999; i++) { is_prime[i] = true; } is_prime[0] = is_prime[1] = false; for (int i = 2; i <= 999999; i++) { if (is_prime[i]) { prime[p++] = i; for (int j = 2 * i; j <= 999999; j += i) { is_prime[j] = false; } } } int n; while (scanf_s("%d", &n) != EOF) { int i = 0; while (prime[i] <= n) { i++; } cout << i << endl; } }
a.cc: In function 'int main()': a.cc:32:16: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'? 32 | while (scanf_s("%d", &n) != EOF) { | ^~~~~~~ | scanf
s764844188
p00009
C++
#include <iostream> using namespace std; int main(){ int number,cnt=0; cin>>number; int* arr = new int[number+1]; for (int i = 1; i <= number; i+=2) { arr[i-1]=0; arr[i]=1; } for (int i = 3; i < sqrt(number); i+=2) if (arr[i]) for (int j = i+i; j <=number; j+=i) arr[j]=0; arr[2]=1;arr[1]=0; for (int i = 0; i < number; i++) if (arr[i]) ++cnt; cout<<cnt; }
a.cc: In function 'int main()': a.cc:14:29: error: 'sqrt' was not declared in this scope 14 | for (int i = 3; i < sqrt(number); i+=2) | ^~~~
s893953713
p00009
C++
int main() { bool num[1000000]={false}; for(int i=2;i<1000;i++){ if(!num[i]){ for(int j=i*i;j<1000000;j+=i){ num[j]=true; } } } int n; while(cin>>n){ int ans=0; for(int i=2;i<=n;i++){ if(!num[i]) ans++; } cout<<ans<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:13:11: error: 'cin' was not declared in this scope 13 | while(cin>>n){ | ^~~ a.cc:19:9: error: 'cout' was not declared in this scope 19 | cout<<ans<<endl; | ^~~~ a.cc:19:20: error: 'endl' was not declared in this scope 19 | cout<<ans<<endl; | ^~~~
s548151893
p00009
C++
#include<iostream> #include<stdio.h> using namespace std; typedef long long ll; const ll MAX=1e6; ll prime[MAX+2],mark[MAX+2],ans[MAX+2]; void Prime(){ memset(mark,0,sizeof(mark)); ll index=0; for(ll i=2;i<=MAX;i++){ if(mark[i]) continue; else{ prime[++index]=i; for(ll j=i*i;j<=MAX;j+=i){ mark[j]=1; } } } } int main(){ ll a; memset(ans,0,sizeof(ans)); Prime(); for(int i=2;i<=MAX-2;i++){ if(mark[i]==0) ans[i]=ans[i-1]+1; else ans[i]=ans[i-1]; } while(scanf("%I64d",&a)!=EOF){ cout<<ans[a]<<endl;; } return 0; }
a.cc: In function 'void Prime()': a.cc:8:5: error: 'memset' was not declared in this scope 8 | memset(mark,0,sizeof(mark)); | ^~~~~~ 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<stdio.h> a.cc: In function 'int main()': a.cc:22:5: error: 'memset' was not declared in this scope 22 | memset(ans,0,sizeof(ans)); | ^~~~~~ a.cc:22:5: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
s147879697
p00009
C++
#include <iostream> #include <vector> #include <numeric> using namespace std; int main() { int n; vector<int> v; while (cin >> n) { if (v.size() > n) { cout << accmulate(v.begin(), v.end() - (v.size() - n), 0) << endl; } v.resize(n + 1); fill(v.begin(), v.end(), 1); v[0] = 0; v[1] = 0; for (int i = 0; i * i < v.size(); ++i) { while (v[i] == 0) ++i; for (int m = i + 1; m < v.size(); ++m) { if (m % i == 0) { v[m] = 0; } } } cout << accumulate(v.begin(), v.end(), 0) << endl; } return 0; }
a.cc: In function 'int main()': a.cc:10:15: error: 'accmulate' was not declared in this scope 10 | cout << accmulate(v.begin(), v.end() - (v.size() - n), 0) << endl; | ^~~~~~~~~
s213878241
p00009
C++
/* Volume0-0009 */ //#include <iostream> #include <stdio.h> #include <stdlib.h> #define N 1000000 #define TRUE (int)(0==0) #define FALSE !TRUE #define BUFLEN 1024 //using std; int syserr(char *str) { fputs(str, stderr); exit(-1); } int main(int argc, char *argv[]){ int f[N]; memset(f, TRUE, N); f[1]=FALSE; for (int i=3; i<N; i++){ if (f[i] == TRUE ) { for (int j=i+i; j<N; j+=i){ f[j] = FALSE; } } } for (int i=3; i<N; i+=2) { if (f[i/2-1]) { x = x + 1; } f[i/2-1]=x; } char buf[BUFLEN]; while (fgets(buf, BUFLEN, stdin) != NULL){ int n = atoi(buf); int m = 0; for (int i=1; i<=n; i++){ if (f[i]){ m++; } } printf("%d\n", m); exit(0); }
a.cc: In function 'int main(int, char**)': a.cc:22:3: error: 'memset' was not declared in this scope 22 | memset(f, TRUE, N); | ^~~~~~ a.cc:7:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 6 | #include <stdlib.h> +++ |+#include <cstring> 7 | a.cc:34:7: error: 'x' was not declared in this scope 34 | x = x + 1; | ^ a.cc:36:14: error: 'x' was not declared in this scope 36 | f[i/2-1]=x; | ^ a.cc:52:2: error: expected '}' at end of input 52 | } | ^ a.cc:19:33: note: to match this '{' 19 | int main(int argc, char *argv[]){ | ^
s333963668
p00009
C++
/* Volume0-0009 */ #include <iostream> #include <stdlib.h> #include <string.h> #define N 1000000 #define TRUE (int)(0==0) #define FALSE !TRUE #define BUFLEN 1024 using namespace std; int main(int argc, char *argv[]){ int f[N]; // memset(f, TRUE, N); f[0]=FALSE; f[1]=FALSE; for (int i=2; i<N; i++) f[i] = TRUE; for (int i=2; i<N; i++){ if (f[i] == TRUE ) { for (int j=i+i; j<N; j+=i){ f[j] = FALSE; } } } while (cin >> int n) != NULL){ int m = 0; for (i=1; i<=n; i++){ if (f[i]){ m++; } } cout << m; } exit(0); }
a.cc: In function 'int main(int, char**)': a.cc:32:17: error: expected primary-expression before 'int' 32 | while (cin >> int n) != NULL){ | ^~~ a.cc:32:16: error: expected ')' before 'int' 32 | while (cin >> int n) != NULL){ | ~ ^~~~ | ) a.cc:32:22: error: expected initializer before ')' token 32 | while (cin >> int n) != NULL){ | ^
s529819225
p00009
C++
/* Volume0-0009 */ #include <iostream> #include <stdlib.h> #include <string.h> #define N 1000000 #define TRUE (int)(0==0) #define FALSE !TRUE using namespace std; int main(int argc, char *argv[]){ int f[N]; // memset(f, TRUE, N); f[0]=FALSE; f[1]=FALSE; for (int i=2; i<N; i++) f[i] = TRUE; for (int i=2; i<N; i++){ if (f[i] == TRUE ) { for (int j=i+i; j<N; j+=i){ f[j] = FALSE; } } } int n; while (cin >> n) != NULL){ int m = 0; for (i=1; i<=n; i++){ if (f[i]){ m++; } } cout << m; } exit(0); }
a.cc: In function 'int main(int, char**)': a.cc:31:20: error: expected primary-expression before '!=' token 31 | while (cin >> n) != NULL){ | ^~
s289749224
p00009
C++
#include<stdio.h> #include<Math.h> int main(){ int n; int a[10000]; int b; int i, j, p; int c[30]; p = 0; while (scanf("%d", &n) != EOF){ b = (int)pow((double)n, 0.5); c[p] = 0; a[0] = -1; for (i = 2; i <= b; i++){ for (j = 2; j <= n / i; j++){ a[i*j - 1] = -1; } } for (i = 1; i <= n; i++){ if (a[i - 1] != -1){ c[p]++; } a[i - 1] = 0; } p++; } for (i = 0; i < p; i++){ printf("%d\n", c[i]); } return 0; }
a.cc:2:9: fatal error: Math.h: No such file or directory 2 | #include<Math.h> | ^~~~~~~~ compilation terminated.
s353696970
p00009
C++
#include<stdio.h> #include<Math.h> int main(){ int n; int a[1000]; int b; int i, j, p; int c[30]; p = 0; while (scanf("%d", &n) != EOF){ b = (int)pow((double)n, 0.5); c[p] = 0; a[0] = -1; for (i = 2; i <= b; i++){ for (j = 2; j <= n / i; j++){ a[i*j - 1] = -1; } } for (i = 1; i <= n; i++){ if (a[i - 1] != -1){ c[p]++; } a[i - 1] = 0; } p++; } for (i = 0; i < p; i++){ printf("%d\n", c[i]); } return 0; }
a.cc:2:9: fatal error: Math.h: No such file or directory 2 | #include<Math.h> | ^~~~~~~~ compilation terminated.
s782372524
p00009
C++
#include<stdio.h> #include<Math.h> int main(){ int n; int a[100000]; int b; int i, j, p; int c[30]; p = 0; while (scanf("%d", &n) != EOF){ b = (int)pow((double)n, 0.5); c[p] = 0; a[0] = -1; for (i = 2; i <= b; i++){ for (j = 2; j <= n / i; j++){ a[i*j - 1] = -1; } } for (i = 1; i <= n; i++){ if (a[i - 1] != -1){ c[p]++; } a[i - 1] = 0; } p++; } for (i = 0; i < p; i++){ printf("%d\n", c[i]); } return 0; }
a.cc:2:9: fatal error: Math.h: No such file or directory 2 | #include<Math.h> | ^~~~~~~~ compilation terminated.
s368548716
p00009
C++
import numpy def get_input(): while True: try: yield ''.join(input()) except EOFError: break def primesfrom3to(n): sieve = numpy.ones(int(n/2), dtype=numpy.bool) if n%2 != 0: sieve = numpy.append(sieve,n/2) for i in range(3,int(n**0.5)+1,2): if sieve[int(i/2)]: sieve[int(i*i/2)::int(i)] = False return 2*numpy.nonzero(sieve)[0][1::]+1 if __name__ == "__main__": array = list(get_input()) for i in range(int(len(array))): primeList = list(primesfrom3to(int(array[i]))) primeList.insert(0,2) #print(primeList) print(len(primeList))
a.cc:5:19: error: empty character constant 5 | yield ''.join(input()) | ^~ a.cc:21:10: error: invalid preprocessing directive #print 21 | #print(primeList) | ^~~~~ a.cc:1:1: error: 'import' does not name a type 1 | import numpy | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
s992152910
p00009
C++
#include<iostream> using namespace std; int main(){ int a,i; cin>>a; for(int x=0;x<a;x++){ if(a%x){i++} cout<<i<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:7:12: error: expected ';' before '}' token 7 | if(a%x){i++} | ^ | ;
s672206289
p00009
C++
#include<iostream> using namespace std; int main(){ int a,i; cin>>a; for(int x=2x<a;x++){ if(a%x==0){i++} cout<<i<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:6:11: error: unable to find numeric literal operator 'operator""x' 6 | for(int x=2x<a;x++){ | ^~ a.cc:6:19: error: expected ';' before ')' token 6 | for(int x=2x<a;x++){ | ^ | ; a.cc:7:15: error: expected ';' before '}' token 7 | if(a%x==0){i++} | ^ | ;
s146440262
p00009
C++
#include<iostream> using namespace std; int main(){ int a,i; for(;;){ cin>>a; for(int x=2x<a;x++){ if(a%x==0){i++} cout<<i<<endl; } } return 0; }
a.cc: In function 'int main()': a.cc:7:11: error: unable to find numeric literal operator 'operator""x' 7 | for(int x=2x<a;x++){ | ^~ a.cc:7:19: error: expected ';' before ')' token 7 | for(int x=2x<a;x++){ | ^ | ; a.cc:8:15: error: expected ';' before '}' token 8 | if(a%x==0){i++} | ^ | ;
s033893861
p00009
C++
#include<iostream> using namespace std; int main(){ int a,i; for(;;){ cin>>a; for(int x=2x<a;x++){ if(a%x>0){i++} cout<<i<<endl; } } return 0; }
a.cc: In function 'int main()': a.cc:7:11: error: unable to find numeric literal operator 'operator""x' 7 | for(int x=2x<a;x++){ | ^~ a.cc:7:19: error: expected ';' before ')' token 7 | for(int x=2x<a;x++){ | ^ | ; a.cc:8:14: error: expected ';' before '}' token 8 | if(a%x>0){i++} | ^ | ;
s583172040
p00009
C++
#include<Upstream> #include<cstdio> #include<cstring> using namespace std; Int pn[1000002]; int main(){ int n, Count; con.tie(0); while(scanf("%d",&n)!=EOF){ Count=0; memset(pn,0,n); pn[0]=pn[1]=1; for(int i=0;i<=n;i++) if(!pn[i]) for(int j=0;i*j<=n;j++) pn[i*j]=1; Count=count(pn,pn+n,0); count<<Count<<endl; } return 0; }
a.cc:1:9: fatal error: Upstream: No such file or directory 1 | #include<Upstream> | ^~~~~~~~~~ compilation terminated.
s370620778
p00009
C++
#include<iostream> #include<cstdio> #include<cstring> using namespace std; Int pn[1000002]; int main(){ int n, Count; con.tie(0); while(scanf("%d",&n)!=EOF){ Count=0; memset(pn,0,n); pn[0]=pn[1]=1; for(int i=0;i<=n;i++) if(!pn[i]) for(int j=0;i*j<=n;j++) pn[i*j]=1; Count=count(pn,pn+n,0); count<<Count<<endl; } return 0; }
a.cc:6:1: error: 'Int' does not name a type; did you mean 'int'? 6 | Int pn[1000002]; | ^~~ | int a.cc: In function 'int main()': a.cc:10:1: error: 'con' was not declared in this scope 10 | con.tie(0); | ^~~ a.cc:13:8: error: 'pn' was not declared in this scope; did you mean 'n'? 13 | memset(pn,0,n); | ^~ | n a.cc:16:7: error: 'count' was not declared in this scope; did you mean 'Count'? 16 | Count=count(pn,pn+n,0); | ^~~~~ | Count
s153774177
p00009
C++
#include<iostream> #include<cstdio> #include<cstring> using namespace std; Int pn[1000002]; int main(){ int n, Count; cin.tie(0); while(scanf("%d",&n)!=EOF){ Count=0; memset(pn,0,n); pn[0]=pn[1]=1; for(int i=2;i<=n;i++) if(!pn[i]) for(int j=1;i*j<=n;j++) pn[i*j]=1; Count=count(pn,pn+n,0); cout<<Count<<endl; } return 0; }
a.cc:6:1: error: 'Int' does not name a type; did you mean 'int'? 6 | Int pn[1000002]; | ^~~ | int a.cc: In function 'int main()': a.cc:13:8: error: 'pn' was not declared in this scope; did you mean 'n'? 13 | memset(pn,0,n); | ^~ | n a.cc:16:7: error: 'count' was not declared in this scope; did you mean 'Count'? 16 | Count=count(pn,pn+n,0); | ^~~~~ | Count
s724053584
p00009
C++
#include<iostream> #include<cstdio> #include<cstring> using namespace std; int pn[1000002]; int main(){ int n, Count; cin.tie(0); while(scanf("%d",&n)!=EOF){ Count=0; memset(pn,0,n); pn[0]=pn[1]=1; for(int i=2;i<=n;i++) if(!pn[i]) for(int j=1;i*j<=n;j++) pn[i*j]=1; Count=count(pn,pn+n,0); cout<<Count<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:16:7: error: 'count' was not declared in this scope; did you mean 'Count'? 16 | Count=count(pn,pn+n,0); | ^~~~~ | Count
s193053201
p00009
C++
import java.util.Scanner; class Main { public static void main(String[] a) { String input; int datasetCount = 0; Scanner stdin = new Scanner(System.in); while (++datasetCount <= 30) { int primes = 0; input = stdin.nextLine(); try { int n = Integer.parseUnsignedInt(input); if (n > 999999) break; for (int i = 2; i <= n; ++i) { if (isPrime(i)) ++primes; } System.out.print(primes); } catch (NumberFormatException nfe) { break; } } stdin.close(); } private static boolean isPrime(int i) { for (int div = 2; div <= Math.sqrt(i); ++div) { if (i % div == 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:5:15: error: expected ':' before 'static' 5 | public static void main(String[] a) { | ^~~~~~~ | : a.cc:5:33: error: 'String' has not been declared 5 | public static void main(String[] a) { | ^~~~~~ a.cc:5:42: error: expected ',' or '...' before 'a' 5 | public static void main(String[] a) { | ^ a.cc:39:16: error: expected ':' before 'static' 39 | private static boolean isPrime(int i) { | ^~~~~~~ | : a.cc:39:24: error: 'boolean' does not name a type; did you mean 'bool'? 39 | private static boolean isPrime(int i) { | ^~~~~~~ | bool a.cc:47:2: error: expected ';' after class definition 47 | } | ^ | ; a.cc: In static member function 'static void Main::main(int*)': a.cc:7:17: error: 'String' was not declared in this scope 7 | String input; | ^~~~~~ a.cc:11:17: error: 'Scanner' was not declared in this scope 11 | Scanner stdin = new Scanner(System.in); | ^~~~~~~ a.cc:14:25: error: 'input' was not declared in this scope; did you mean 'int'? 14 | input = stdin.nextLine(); | ^~~~~ | int a.cc:14:33: error: 'stdin' was not declared in this scope 14 | input = stdin.nextLine(); | ^~~~~ a.cc:1:1: note: 'stdin' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' +++ |+#include <cstdio> 1 | import java.util.Scanner; a.cc:16:41: error: 'Integer' was not declared in this scope 16 | int n = Integer.parseUnsignedInt(input); | ^~~~~~~ a.cc:23:45: error: 'isPrime' was not declared in this scope 23 | if (isPrime(i)) | ^~~~~~~ a.cc:28:33: error: 'System' was not declared in this scope 28 | System.out.print(primes); | ^~~~~~ a.cc:31:34: error: 'NumberFormatException' does not name a type 31 | } catch (NumberFormatException nfe) { | ^~~~~~~~~~~~~~~~~~~~~ a.cc:35:17: error: 'stdin' was not declared in this scope 35 | stdin.close(); | ^~~~~ a.cc:35:17: note: 'stdin' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
s459344956
p00009
C++
#include <iostream> #include <vector> #define pb(a) push_back(a) #define rep(i,a,n) for(int i=a; i<n; i++) using namespace std; int main() { int n = 1000000; vector<int> v; v.pb(2); for(int i=3;i<=n;i+=2) { bool add = true; rep(j,0,v.size()) { if(v[j] * v[j] > i) break; if(i % v[j] == 0) { add = false; break; } } if(add) v.pb(i); } int m; while(cin >> m) { cout << upper_bound(v.begin(), v.end(), m) - v.begin() << endl; } return 0; }
a.cc: In function 'int main()': a.cc:25:17: error: 'upper_bound' was not declared in this scope 25 | cout << upper_bound(v.begin(), v.end(), m) - v.begin() << endl; | ^~~~~~~~~~~
s544604128
p00009
C++
import java.util.Scanner; import java.io.*; class Main{ public static void main(String[] args){ Scanner sc =new Scanner(System.in); int ans,n; while(sc.hasNext()){ n=sc.nextInt(); ans=0; if(n==1)ans=-1; for(int i=1;i<=n;i+=2){ int flag=0; for(int j=3;j<=Math.sqrt(i);j+=2){ if(i%j==0){ flag=1;break; } } if(flag==0)ans++; } System.out.println(ans); } } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.util.Scanner; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import java.io.*; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:11: error: expected ':' before 'static' 4 | public static void main(String[] args){ | ^~~~~~~ | : a.cc:4:29: error: 'String' has not been declared 4 | public static void main(String[] args){ | ^~~~~~ a.cc:4:38: error: expected ',' or '...' before 'args' 4 | public static void main(String[] args){ | ^~~~ a.cc:23:2: error: expected ';' after class definition 23 | } | ^ | ; a.cc: In static member function 'static void Main::main(int*)': a.cc:5:5: error: 'Scanner' was not declared in this scope 5 | Scanner sc =new Scanner(System.in); | ^~~~~~~ a.cc:7:11: error: 'sc' was not declared in this scope 7 | while(sc.hasNext()){ | ^~ a.cc:13:32: error: 'Math' was not declared in this scope 13 | for(int j=3;j<=Math.sqrt(i);j+=2){ | ^~~~ a.cc:20:9: error: 'System' was not declared in this scope 20 | System.out.println(ans); | ^~~~~~
s769854611
p00009
C++
#include<iostream> using namespace std; int main(){ int a[999999]={0,0,1,2},n,k=0;count=2; for(int i=4;i<999999;i++){ for(int j=2;j*j<=i;j++){ if(i%j==0)k++; } if(k==1)count++; a[i]=count; k=0; } while(cin>>n)cout<<a[n]<<endl; return 0; }
a.cc: In function 'int main()': a.cc:4:39: error: 'count' was not declared in this scope 4 | int a[999999]={0,0,1,2},n,k=0;count=2; | ^~~~~
s270000297
p00009
C++
#include&<iostream> #include&<vector> using namespace std; int main(){ int n,k,sum,check; int t=1; vector<int> prime; prime.push_back(0); prime.push_back(0); for(int i=2;i<1000000;i++){ prime.push_back(1); } while(t<1000000){ for(int j=t+1;j<=1000000;j++){ if(prime[j]==1){ t=j; for(k=2*j;k<=1000000;k+=j){ prime[k]=0; } break; } else if(j==1000000){ t=1000000; } } } while(cin>>n){ sum=0; for(check=1;check<=n;check++){ if(prime[check]==1){ sum+=1; } } cout << sum << endl; } return 0; }
a.cc:1:9: error: #include expects "FILENAME" or <FILENAME> 1 | #include&<iostream> | ^ a.cc:2:9: error: #include expects "FILENAME" or <FILENAME> 2 | #include&<vector> | ^ a.cc: In function 'int main()': a.cc:7:5: error: 'vector' was not declared in this scope 7 | vector<int> prime; | ^~~~~~ a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>' +++ |+#include <vector> 1 | #include&<iostream> a.cc:7:12: error: expected primary-expression before 'int' 7 | vector<int> prime; | ^~~ a.cc:8:5: error: 'prime' was not declared in this scope 8 | prime.push_back(0); | ^~~~~ a.cc:27:11: error: 'cin' was not declared in this scope 27 | while(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 | #include&<iostream> a.cc:34:9: error: 'cout' was not declared in this scope 34 | cout << sum << endl; | ^~~~ a.cc:34:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:34:24: error: 'endl' was not declared in this scope 34 | cout << sum << endl; | ^~~~ a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' +++ |+#include <ostream> 1 | #include&<iostream>
s726889194
p00009
C++
#include<iostream> using namespace std; int main(){ int n, cnt; int N = 1000000; bool num[N] = true; num[0] = false; num[1] = false; for(int i = 2; i*i <= N; i++){ if(num[i]){ for(int j = i; i*j < N; j++){ num[i*j] = false; } } } while(cin >> n){ for(int i = 1; i < n; i++) if(num[i]) cnt++; cout << cnt << endl; } }
a.cc: In function 'int main()': a.cc:6:23: error: array must be initialized with a brace-enclosed initializer 6 | bool num[N] = true; | ^~~~
s072715176
p00009
C++
#include<iostream> using namespace std; int main(){ int n, cnt; int N = 1000000; bool prime[N] = false; prime[1] = true; //1???????????\ while(cin >> n){ // ??¨?????????????????????????????? for(int j = 2; j*j <= n; j++){ if(prime[j] == false){ for(int k = j; k*j <= n; k++){ prime[j*k] =true; } } } for(int i = 1; i <= n; i++){ if(prime[i] == false) cnt++; } cout << cnt << endl; } }
a.cc: In function 'int main()': a.cc:6:25: error: array must be initialized with a brace-enclosed initializer 6 | bool prime[N] = false; | ^~~~~
s879799251
p00009
C++
#include<iostream> using namespace std; int main(){ int n, cnt; bool prime[1000000] = false; prime[1] = true; //1???????????\ while(cin >> n){ // ??¨?????????????????????????????? for(int j = 2; j*j <= n; j++){ if(prime[j] == false){ for(int k = j; k*j <= n; k++){ prime[j*k] =true; } } } for(int i = 1; i <= n; i++){ if(prime[i] == false) cnt++; } cout << cnt << endl; } }
a.cc: In function 'int main()': a.cc:5:31: error: array must be initialized with a brace-enclosed initializer 5 | bool prime[1000000] = false; | ^~~~~
s229853380
p00009
C++
#include <iostream> #include <cmath> using namespace std; int main() { int n; int count=0; while(cin >> n){ double nd=(double)n; int root=(int)sqrt(nd); for(int i=2;i<=n;i++){ for(int j=2;j<=root;j++){ if(i%j==0) break; } if(j==root) count++; } cout << count << endl; } return 0; }
a.cc: In function 'int main()': a.cc:17:10: error: 'j' was not declared in this scope 17 | if(j==root) count++; | ^
s652989060
p00009
C++
$inputArray = array(); while (!feof(STDIN)) { $input = trim(fgets(STDIN)); if (empty($input)) { break; } array_push($inputArray, $input); } foreach ($inputArray as $input) { $count = 0; for ($i = 2; $i <= $input; $i++) { if (isSosu($i)) { $count++; } } echo $count . "\n"; } function isSosu($num) { $count = 0; for ($i = 2; $i < $num; $i++) { if ($num % $i == 0) { $count++; } } if ($count == 0) { return true; } else { return false; } }
a.cc:1:1: error: '$inputArray' does not name a type 1 | $inputArray = array(); | ^~~~~~~~~~~ a.cc:2:1: error: expected unqualified-id before 'while' 2 | while (!feof(STDIN)) { | ^~~~~ a.cc:10:9: error: expected constructor, destructor, or type conversion before '(' token 10 | foreach ($inputArray as $input) { | ^ a.cc:20:1: error: 'function' does not name a type; did you mean 'union'? 20 | function isSosu($num) { | ^~~~~~~~ | union
s623459228
p00009
C++
int main() { bool isPrime[1000000] = {true}; for (int i = 0; i < 1000000; i++) { isPrime[i] = true; } isPrime[1] = false; for (int i = 2; i < 1000000; i++) { if (!isPrime[i]) continue; if (isPrime[i]) { int k = 2*i; while (k < 1000000) { isPrime[k] = false; k += i; } } } int n; while (cin >> n) { int sum = 0; for (int i = 2; i <= n; i++) { if (isPrime[i]) sum++; } cout << sum << endl; } return 0; }
a.cc: In function 'int main()': a.cc:23:16: error: 'cin' was not declared in this scope 23 | while (cin >> n) { | ^~~ a.cc:29:17: error: 'cout' was not declared in this scope 29 | cout << sum << endl; | ^~~~ a.cc:29:32: error: 'endl' was not declared in this scope 29 | cout << sum << endl; | ^~~~
s123319973
p00009
C++
???#include <iostream> using namespace std; int main() { unsigned int n; cin >> n; unsigned int num, count = 0; for(int i = 0; i < n; i++) { cin >> num; for(int j = 2; j < num; j++) { if(num % j == 0) { break; } if(num - 1 == j) { count++; } } if(num == 2) { count++; } } cout << count << std::endl; return 0; }
a.cc:1:4: error: stray '#' in program 1 | ???#include <iostream> | ^ a.cc:1:1: error: expected unqualified-id before '?' token 1 | ???#include <iostream> | ^ a.cc: In function 'int main()': a.cc:8:9: error: 'cin' was not declared in this scope 8 | cin >> n; | ^~~ a.cc:29:9: error: 'cout' was not declared in this scope; did you mean 'count'? 29 | cout << count << std::endl; | ^~~~ | count a.cc:29:31: error: 'endl' is not a member of 'std' 29 | cout << count << 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 | ???#include <iostream>
s034789723
p00009
C++
???#include <iostream> using namespace std; int main() { unsigned int n; cin >> n; unsigned int num, count = 0; for(int i = 0; i < n; i++) { cin >> num; for(int j = 2; j <=num; j++) { if(num == j)count++; if(num % j == 0) { break; } } } cout << count << endl; return 0; }
a.cc:1:4: error: stray '#' in program 1 | ???#include <iostream> | ^ a.cc:1:1: error: expected unqualified-id before '?' token 1 | ???#include <iostream> | ^ a.cc: In function 'int main()': a.cc:8:9: error: 'cin' was not declared in this scope 8 | cin >> n; | ^~~ a.cc:22:9: error: 'cout' was not declared in this scope; did you mean 'count'? 22 | cout << count << endl; | ^~~~ | count a.cc:22:26: error: 'endl' was not declared in this scope 22 | cout << count << endl; | ^~~~
s212001579
p00009
C++
???#include <iostream> using namespace std; int main() { unsigned int n; cin >> n; unsigned int num, count = 0; for(int i = 0; i < n; i++) { cin >> num; for(int j = 2; j <=num; j++) { if(num == j)count++; if(num % j == 0) { break; } } } cout << count << endl; return 0; }
a.cc:1:4: error: stray '#' in program 1 | ???#include <iostream> | ^ a.cc:1:1: error: expected unqualified-id before '?' token 1 | ???#include <iostream> | ^ a.cc: In function 'int main()': a.cc:8:9: error: 'cin' was not declared in this scope 8 | cin >> n; | ^~~ a.cc:22:9: error: 'cout' was not declared in this scope; did you mean 'count'? 22 | cout << count << endl; | ^~~~ | count a.cc:22:26: error: 'endl' was not declared in this scope 22 | cout << count << endl; | ^~~~
s901345217
p00009
C++
#include <iostream> #include <algorithm> #include <cstdio> #include <string> using namespace std; int main() { int n, count = 0; int a[9999] = { 0 }; // ??¨??????????????????????????? while (cin >> n){ for (int i = 2; i <= n; i++) { a[i] = 1; } for (int i = 2; i < sqrt(n); i++) { if (a[i]) { for (int j = 0; i*(j + 2) <= n; j++) { a[i * (j + 2)] = 0; } } } for (int i = 2; i <= n; i++) { if (a[i] == 1) count++; } cout << count << endl; count = 0; } return 0; }
a.cc: In function 'int main()': a.cc:21:37: error: 'sqrt' was not declared in this scope 21 | for (int i = 2; i < sqrt(n); i++) { | ^~~~
s143868438
p00009
C++
include<cstdio> #include<iostream> #include<algorithm> using namespace std; int main(){ int n; int num[1000000]={0}; num[0]=1; num[1]=1; for(int i=2;i<1000000;i++){ if(num[i]==0){ for(int j=2;j*i<1000000;j++){ num[j*i]=1; } } } while(scanf(" %d",&n)!=EOF){ int cnt=0; for(int i=2;i<=n;i++){ if(num[i]==0){ cnt++; } } cout << cnt << endl; } return 0;
a.cc:1:1: error: 'include' does not name a type 1 | include<cstdio> | ^~~~~~~ In file included from /usr/include/c++/14/iosfwd:42, from /usr/include/c++/14/ios:40, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:2: /usr/include/c++/14/bits/postypes.h:68:11: error: 'ptrdiff_t' does not name a type 68 | typedef ptrdiff_t streamsize; // Signed integral type | ^~~~~~~~~ /usr/include/c++/14/bits/postypes.h:41:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 40 | #include <cwchar> // For mbstate_t +++ |+#include <cstddef> 41 | In file included from /usr/include/c++/14/bits/exception_ptr.h:38, from /usr/include/c++/14/exception:166, from /usr/include/c++/14/ios:41: /usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function 131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~~~ /usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~ In file included from /usr/include/wchar.h:35, from /usr/include/c++/14/cwchar:44, from /usr/include/c++/14/bits/postypes.h:40: /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/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive] 132 | __attribute__((__externally_visible__)); | ^ /usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function 133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~~~ /usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~ /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/new:134:41: error: attributes after parenthesized initializer ignored [-fpermissive] 134 | __attribute__((__externally_visible__)); | ^ /usr/include/c++/14/new:140:29: error: 'std::size_t' has not been declared 140 | void operator delete(void*, std::size_t) _GLIBCXX_USE_NOEXCEPT | ^~~ /usr/include/c++/14/new:142:31: error: 'std::size_t' has not been declared 142 | void operator delete[](void*, std::size_t) _GLIBCXX_USE_NOEXCEPT | ^~~ /usr/include/c++/14/new:145:26: error: declaration of 'operator new' as non-function 145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~~~~ /usr/include/c++/14/new:145:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~~ /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/new:145:52: error: expected primary-expression before 'const' 145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~ /usr/include/c++/14/new:147:26: error: declaration of 'operator new []' as non-function 147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~~~~ /usr/include/c++/14/new:147:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~~ /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/new:147:54: error: expected primary-expression before 'const' 147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~ /usr/include/c++/14/new:154:26: error: declaration of 'operator new' as non-function 154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t) | ^~~~~~~~ /usr/include/c++/14/new:154:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t) | ^~~~~~ /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/new:154:68: error: expected primary-expression before ')' token 154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t) | ^ /usr/include/c++/14/new:155:73: error: attributes after parenthesized initializer ignored [-fpermissive] 155 | __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); | ^ /usr/include/c++/14/new:156:26: error: declaration of 'operator new' as non-function 156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~~~~ /usr/include/c++/14/new:156:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~~ /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/new:156:68: error: expected primary-expression before ',' token 156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) | ^ /usr/include/c++/14/new:156:70: error: expected primary-expression before 'const' 156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~ /usr/include/c++/14/new:162:26: error: declaration of 'operator new []' as non-function 162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t) | ^~~~~~~~ /usr/include/c++/14/new:162:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t) | ^~~~~~ /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/new:162:70: error: expected primary-expression before ')' token 162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t) | ^ /usr/include/c++/14/new:163:73: error: attributes after parenthesized initializer ignored [-fpermissive] 163 | __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); | ^ /usr/include/c++/14/new:164:26: error: declaration of 'operator new []' as non-function 164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~~~~ /usr/include/c++/14/new:164:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~~ /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/new:164:70: error: expected primary-expression before ',' token 164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) | ^ /usr/include/c++/14/new:164:72: error: expected primary-expression before 'const' 164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~ /usr/include/c++/14/new:171:29: error: 'std::size_t' has not been declared 171 | void operator delete(void*, std::size_t, std::align_val_t) | ^~~ /usr/include/c++/14/new:173:31: error: 'std::size_t' has not been declared 173 | void operator delete[](void*, std::size_t, std::align_val_t) | ^~~ /usr/include/c++/14/new:179:33: error: declaration of 'operator new' as non-function 179 | _GLIBCXX_NODISCARD inline void* operator new(std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT | ^~~~~~~~ /usr/include/c++/14/new:179:51: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 179 | _GLIBCXX_NO
s839319122
p00009
C++
include<cstdio> #include<iostream> #include<algorithm> using namespace std; int main(){ int n; int num[1000000]={0}; num[0]=1; num[1]=1; for(int i=2;i<1000000;i++){ if(num[i]==0){ for(int j=2;j*i<1000000;j++){ num[j*i]=1; } } } while(scanf(" %d",&n)!=EOF){ int cnt=0; for(int i=2;i<=n;i++){ if(num[i]==0){ cnt++; } } cout << cnt << endl; } return 0; }
a.cc:1:1: error: 'include' does not name a type 1 | include<cstdio> | ^~~~~~~ In file included from /usr/include/c++/14/iosfwd:42, from /usr/include/c++/14/ios:40, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:2: /usr/include/c++/14/bits/postypes.h:68:11: error: 'ptrdiff_t' does not name a type 68 | typedef ptrdiff_t streamsize; // Signed integral type | ^~~~~~~~~ /usr/include/c++/14/bits/postypes.h:41:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 40 | #include <cwchar> // For mbstate_t +++ |+#include <cstddef> 41 | In file included from /usr/include/c++/14/bits/exception_ptr.h:38, from /usr/include/c++/14/exception:166, from /usr/include/c++/14/ios:41: /usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function 131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~~~ /usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~ In file included from /usr/include/wchar.h:35, from /usr/include/c++/14/cwchar:44, from /usr/include/c++/14/bits/postypes.h:40: /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/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive] 132 | __attribute__((__externally_visible__)); | ^ /usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function 133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~~~ /usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~ /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/new:134:41: error: attributes after parenthesized initializer ignored [-fpermissive] 134 | __attribute__((__externally_visible__)); | ^ /usr/include/c++/14/new:140:29: error: 'std::size_t' has not been declared 140 | void operator delete(void*, std::size_t) _GLIBCXX_USE_NOEXCEPT | ^~~ /usr/include/c++/14/new:142:31: error: 'std::size_t' has not been declared 142 | void operator delete[](void*, std::size_t) _GLIBCXX_USE_NOEXCEPT | ^~~ /usr/include/c++/14/new:145:26: error: declaration of 'operator new' as non-function 145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~~~~ /usr/include/c++/14/new:145:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~~ /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/new:145:52: error: expected primary-expression before 'const' 145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~ /usr/include/c++/14/new:147:26: error: declaration of 'operator new []' as non-function 147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~~~~ /usr/include/c++/14/new:147:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~~ /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/new:147:54: error: expected primary-expression before 'const' 147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~ /usr/include/c++/14/new:154:26: error: declaration of 'operator new' as non-function 154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t) | ^~~~~~~~ /usr/include/c++/14/new:154:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t) | ^~~~~~ /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/new:154:68: error: expected primary-expression before ')' token 154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t) | ^ /usr/include/c++/14/new:155:73: error: attributes after parenthesized initializer ignored [-fpermissive] 155 | __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); | ^ /usr/include/c++/14/new:156:26: error: declaration of 'operator new' as non-function 156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~~~~ /usr/include/c++/14/new:156:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~~ /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/new:156:68: error: expected primary-expression before ',' token 156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) | ^ /usr/include/c++/14/new:156:70: error: expected primary-expression before 'const' 156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~ /usr/include/c++/14/new:162:26: error: declaration of 'operator new []' as non-function 162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t) | ^~~~~~~~ /usr/include/c++/14/new:162:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t) | ^~~~~~ /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/new:162:70: error: expected primary-expression before ')' token 162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t) | ^ /usr/include/c++/14/new:163:73: error: attributes after parenthesized initializer ignored [-fpermissive] 163 | __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); | ^ /usr/include/c++/14/new:164:26: error: declaration of 'operator new []' as non-function 164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~~~~ /usr/include/c++/14/new:164:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~~ /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/new:164:70: error: expected primary-expression before ',' token 164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) | ^ /usr/include/c++/14/new:164:72: error: expected primary-expression before 'const' 164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~ /usr/include/c++/14/new:171:29: error: 'std::size_t' has not been declared 171 | void operator delete(void*, std::size_t, std::align_val_t) | ^~~ /usr/include/c++/14/new:173:31: error: 'std::size_t' has not been declared 173 | void operator delete[](void*, std::size_t, std::align_val_t) | ^~~ /usr/include/c++/14/new:179:33: error: declaration of 'operator new' as non-function 179 | _GLIBCXX_NODISCARD inline void* operator new(std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT | ^~~~~~~~ /usr/include/c++/14/new:179:51: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 179 | _GLIBCXX_NO
s867573013
p00009
C++
#include<iostream> #include<vector> using namespace std; #define MAX_N 100001 int main(){ int n; while(cin >> n){ vector<int> vec; vector<int>::iterator it =vec.begin(); for(int i=2;i<=n;i++){ int flag=0; it =vec.begin(); while(it!= vec.end()){ if(i% *it==0){ flag=1; break; } it++; } if(!flag)vec.push_back(i); } it =vec.begin(); //while(it!= vec.end()){ // cout<<*it<<endl; // it++; //} cout << vec.size()<<endl; }
a.cc: In function 'int main()': a.cc:28:10: error: expected '}' at end of input 28 | } | ^ a.cc:5:11: note: to match this '{' 5 | int main(){ | ^
s561551737
p00009
C++
#include<iostream> #include<vector> using namespace std; #define MAX_N 100001 int main(){ int n; while(cin >> n){ vector<int> vec; vector<int>::iterator it =vec.begin(); for(int i=2;i<=n;i++){ int flag=0; it =vec.begin(); while(it!= vec.end()){ if(i% *it==0){ flag=1; break; } it++; } if(!flag)vec.push_back(i); } it =vec.begin(); //while(it!= vec.end()){ // cout<<*it<<endl; // it++; //} cout << vec.size()<<endl; }
a.cc: In function 'int main()': a.cc:28:10: error: expected '}' at end of input 28 | } | ^ a.cc:5:11: note: to match this '{' 5 | int main(){ | ^
s205063957
p00009
C++
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <set> #include <map> #include <cmath> #include <cstudio> //ranker using namespace std; #define REPS(i, a, n) for (int i = (a); i < (n); ++i) #define REP(i, n) REPS(i, 0, n) #define RREP(i, n) REPS(i, 1, n + 1) #define DEPS(i, a, n) for (int i = (a); i >= n; --i) #define DEP(i, n) DEPS(i, n, 0) using ll = long long; using ull = unsigned long long; using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>; using pii = pair<int, int>; using pis = pair<int, string>; using psi = pair<string, int>; using D = double; const int Max=10000000; bool prime[Max]; int main(void){ int in; for(int i=0;i<Max;i++)prime[i]=true; prime[1]=false; for(int i=2;i<Max;i++){ if(prime[i]){ for(int s=i*2;s<=Max;s+=i)prime[s]=false; } } while(cin>>in){ int cnt=0; for(int i=1;i<=in;i++){ if(prime[i])cnt++; } cout << cnt << "\n"; } return 0; }
a.cc:8:10: fatal error: cstudio: No such file or directory 8 | #include <cstudio> | ^~~~~~~~~ compilation terminated.
s235142955
p00009
C++
#include <iostream> #include <string> #include <array> using namespace std; int main(void){ const int n = 1000000; bool* check_A = (bool*)malloc(sizeof(bool)*n); int* num_A = (int*)malloc(sizeof(int)*n); int N = 0, temp = 2; memset(check_A, true, n); check_A[0] = false; check_A[1] = false; num_A[0] = 0; num_A[1] = 0; for(int i = 0; i < n; i++){ if(check_A[i]){ for(;temp < i;temp++){ num_A[temp] = N; } temp++; num_A[i] = ++N; for(int j = 2; i*j < n; j++){ check_A[i*j] = false; } } } int s; while(cin >> s){ cout << num_A[s] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:12:3: error: 'memset' was not declared in this scope 12 | memset(check_A, true, n); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include <array> +++ |+#include <cstring> 4 |
s113948072
p00009
C++
#include <iostream> #include <string> using namespace std; int main(void){ const int n = 1000000; bool* check_A = (bool*)malloc(sizeof(bool)*n); int* num_A = (int*)malloc(sizeof(int)*n); int N = 0, temp = 2; memset(check_A, true, n); check_A[0] = false; check_A[1] = false; num_A[0] = 0; num_A[1] = 0; for(int i = 0; i < n; i++){ if(check_A[i]){ for(;temp < i;temp++){ num_A[temp] = N; } temp++; num_A[i] = ++N; for(int j = 2; i*j < n; j++){ check_A[i*j] = false; } } } int s; while(cin >> s){ cout << num_A[s] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:11:3: error: 'memset' was not declared in this scope 11 | memset(check_A, true, n); | ^~~~~~ 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>
s179628481
p00009
C++
#include <iostream> #include <string> #include <cstdlib> using namespace std; int main(void){ const int n = 1000000; bool* check_A = (bool*)malloc(sizeof(bool)*n); int* num_A = (int*)malloc(sizeof(int)*n); int N = 0, temp = 2; memset(check_A, true, n); check_A[0] = false; check_A[1] = false; num_A[0] = 0; num_A[1] = 0; for(int i = 0; i < n; i++){ if(check_A[i]){ for(;temp < i;temp++){ num_A[temp] = N; } temp++; num_A[i] = ++N; for(int j = 2; i*j < n; j++){ check_A[i*j] = false; } } } int s; while(cin >> s){ cout << num_A[s] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:12:3: error: 'memset' was not declared in this scope 12 | memset(check_A, true, n); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include <cstdlib> +++ |+#include <cstring> 4 |
s438519163
p00009
C++
#include <iostream> #include <string> #include <cstdlib> using namespace std; int main(void){ const int n = 1000000; bool* check_A = (bool*)malloc(sizeof(bool)*n); int* num_A = (int*)malloc(sizeof(int)*n); int N = 0, temp = 2; memset(check_A, true, n); check_A[0] = false; check_A[1] = false; num_A[0] = 0; num_A[1] = 0; for(int i = 0; i < n; i++){ if(check_A[i]){ for(;temp < i;temp++){ num_A[temp] = N; } temp++; num_A[i] = ++N; for(int j = 2; i*j < n; j++){ check_A[i*j] = false; } } } int s; while(cin >> s){ cout << num_A[s] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:12:3: error: 'memset' was not declared in this scope 12 | memset(check_A, true, n); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include <cstdlib> +++ |+#include <cstring> 4 |
s184980070
p00009
C++
def sieve_prime(n): # return prime numbers within [1, n] primes = [] is_prime = [True] * (n+1) # [0, n] for i in range(2, n+1): if not is_prime[i]: continue # need only primes primes.append(i) for j in range(i*2, n+1, i): # range(i*2, n+1, i) = {i*2, i*3, ...} is_prime[j] = False """ Compare the above code with the below one in the view of time complexity for j in range(i*2, n+1): if j % i == 0: is_prime[j] = False """ return primes while True: try: n = int(input()) print(len(sieve_prime(n))) # because T <= 30, you can simply use sieve_prime every time except EOFError: break
a.cc:1:21: error: stray '#' in program 1 | def sieve_prime(n): # return prime numbers within [1, n] | ^ a.cc:3:29: error: stray '#' in program 3 | is_prime = [True] * (n+1) # [0, n] | ^ a.cc:6:16: error: stray '#' in program 6 | continue # need only primes | ^ a.cc:9:34: error: stray '#' in program 9 | for j in range(i*2, n+1, i): # range(i*2, n+1, i) = {i*2, i*3, ...} | ^ a.cc:12:7: warning: missing terminating " character 12 | """ | ^ a.cc:12:7: error: missing terminating " character a.cc:17:7: warning: missing terminating " character 17 | """ | ^ a.cc:17:7: error: missing terminating " character a.cc:24:32: error: stray '#' in program 24 | print(len(sieve_prime(n))) # because T <= 30, you can simply use sieve_prime every time | ^ a.cc:1:1: error: 'def' does not name a type 1 | def sieve_prime(n): # return prime numbers within [1, n] | ^~~ a.cc:10:7: error: 'is_prime' does not name a type 10 | is_prime[j] = False | ^~~~~~~~
s562564950
p00009
C++
#include <iostream> #include <string> #include <map> #include <vector> #include <set> #include <iomanip> #include <fstream> #include <cstdint> #include <cmath> #include <algorithm> #include <utility> #include <numeric> using namespace std; #define REP(i,f,n) for(int i=(f); i < (n); ++i) #define PER(i,f,n) for(int i=(n-1); i >= f; --i) //---------------------------------- //---------------------------------- constexpr int64_t CALCNUM = 2000000; bool primes[CALCNUM]; signed main() { for(int i = 0; i < CALCNUM; i++) primes[i] = true; ios::sync_with_stdio(false); vector<int> prime; for(int i = 2; i <CALCNUM ; i++) { if(primes[i]) { prime.push_back(i); for(int j = 2 * i; j < CALCNUM; j += i) primes[j] = false; } } int n; while(cin >> n) { for(int i = 0; i < prime.size(); ++i) if(prime[i] > n){ cout << i <<'\n'; break;
a.cc: In function 'int main()': a.cc:46:57: error: expected '}' at end of input 46 | cout << i <<'\n'; break; | ^ a.cc:45:41: note: to match this '{' 45 | if(prime[i] > n){ | ^ a.cc:46:57: error: expected '}' at end of input 46 | cout << i <<'\n'; break; | ^ a.cc:43:9: note: to match this '{' 43 | { | ^ a.cc:46:57: error: expected '}' at end of input 46 | cout << i <<'\n'; break; | ^ a.cc:26:1: note: to match this '{' 26 | { | ^
s600854832
p00009
C++
#include <iostream> #include <vector> #include <algorithm> #include <string> using namespace std; int main() { while (cin) { string tmpstr; int tmp; getline(cin, &tmpstr); tmp = atoi(tmpstr.c_str()); vector<int> prime; for (int i(2); i <= tmp; ++i) { for (vector<int>::iterator i2(prime.begin()), n2(prime.end()); i2 != n2; ++i2) { if ((i % *i2) == 0) { goto nx; } } prime.push_back(i); nx:; } cout << prime.size() << endl; //if (cin.eof()) { break; } } return 0; }
a.cc: In function 'int main()': a.cc:13:24: error: no matching function for call to 'getline(std::istream&, std::string*)' 13 | getline(cin, &tmpstr); | ~~~~~~~^~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:55, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/basic_string.tcc:907:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::getline(basic_istream<_CharT, _Traits>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)' 907 | getline(basic_istream<_CharT, _Traits>& __in, | ^~~~~~~ /usr/include/c++/14/bits/basic_string.tcc:907:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/string:54: /usr/include/c++/14/bits/basic_string.h:4117:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::getline(basic_istream<_CharT, _Traits>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 4117 | getline(basic_istream<_CharT, _Traits>& __is, | ^~~~~~~ /usr/include/c++/14/bits/basic_string.h:4117:5: note: template argument deduction/substitution failed: a.cc:13:24: note: mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'std::string*' {aka 'std::__cxx11::basic_string<char>*'} 13 | getline(cin, &tmpstr); | ~~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/basic_string.h:4125:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::getline(basic_istream<_CharT, _Traits>&&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)' 4125 | getline(basic_istream<_CharT, _Traits>&& __is, | ^~~~~~~ /usr/include/c++/14/bits/basic_string.h:4125:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/basic_string.h:4132:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::getline(basic_istream<_CharT, _Traits>&&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 4132 | getline(basic_istream<_CharT, _Traits>&& __is, | ^~~~~~~ /usr/include/c++/14/bits/basic_string.h:4132:5: note: template argument deduction/substitution failed: a.cc:13:24: note: mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'std::string*' {aka 'std::__cxx11::basic_string<char>*'} 13 | getline(cin, &tmpstr); | ~~~~~~~^~~~~~~~~~~~~~ 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: /usr/include/stdio.h:697:18: note: candidate: '__ssize_t getline(char**, size_t*, FILE*)' 697 | extern __ssize_t getline (char **__restrict __lineptr, | ^~~~~~~ /usr/include/stdio.h:697:18: note: candidate expects 3 arguments, 2 provided
s617734585
p00009
C++
#include <iostream> using namespace std; ?? #define Max 1000000 ?? int prime [10000000]; ?? int main() { ????????int n, out; ?? ????????for (int i = 2; i * i < Max; i++){ ????????????????if (prime[i] == 0){ ????????????????????????for (int j = i; j < Max; j += i){ ????????????????????????????????if (!(j == i)) prime[j] = 1; ????????????????????????} ????????????????} ????????} ?? ????????while (cin >> n){ ????????????????out = 0; ????????????????for (int i = 0; i <= n; i++){ ????????????????????????if (prime[i] == 0) out++; ????????????????} ????????????????cout << out - 2 << endl; ????????} ????????return(0); }
a.cc:3:1: error: expected unqualified-id before '?' token 3 | ?? | ^ a.cc:7:1: error: expected unqualified-id before '?' token 7 | ?? | ^
s840757368
p00009
C++
#include <iostream> using namespace std; ?? #define Max 1000000 ?? int prime [10000000]; ?? int main() { ????????int n, out; ?? ????????for (int i = 2; i * i < Max; i++){ ????????????????if (prime[i] == 0){ ????????????????????????for (int j = i; j < Max; j += i){ ????????????????????????????????if (!(j == i)) prime[j] = 1; ????????????????????????} ????????????????} ????????} ?? ????????while (cin >> n){ ????????????????out = 0; ????????????????for (int i = 0; i <= n; i++){ ????????????????????????if (prime[i] == 0) out++; ????????????????} ????????????????cout << out - 2 << endl; ????????} ????????return(0); }
a.cc:3:1: error: expected unqualified-id before '?' token 3 | ?? | ^ a.cc:7:9: error: expected unqualified-id before '?' token 7 | ?? | ^
s125768623
p00009
C++
#include <iostream> #include <cmath> using namespace std; int whether(int num); int count(int num); int main(){ int n; while(cin >> n){ cout << count(n)+1<<endl; } return 0; } int whether(int num){//if num is prime, 1 int s=sqrt(num); for(int i=3; i<=s; i+=2){ if(num%i==0){ return 0; } } return 1; } int count(int num) if(num==99) return 24; if(num==999) return 167; if(num==9999) return 1228; if(num==99999) return 9591; if(num<2) return 0; if(num==2) return 1; if(num%2==0) return count(num-1); int a; a=whether(num) +count(num-2); return a; }
a.cc:22:5: error: expected initializer before 'if' 22 | if(num==99) return 24; | ^~ a.cc:23:5: error: expected unqualified-id before 'if' 23 | if(num==999) return 167; | ^~ a.cc:24:5: error: expected unqualified-id before 'if' 24 | if(num==9999) return 1228; | ^~ a.cc:25:5: error: expected unqualified-id before 'if' 25 | if(num==99999) return 9591; | ^~ a.cc:26:5: error: expected unqualified-id before 'if' 26 | if(num<2) return 0; | ^~ a.cc:27:5: error: expected unqualified-id before 'if' 27 | if(num==2) return 1; | ^~ a.cc:28:5: error: expected unqualified-id before 'if' 28 | if(num%2==0) return count(num-1); | ^~ a.cc:30:5: error: 'a' does not name a type 30 | a=whether(num) +count(num-2); | ^ a.cc:31:5: error: expected unqualified-id before 'return' 31 | return a; | ^~~~~~ a.cc:32:1: error: expected declaration before '}' token 32 | } | ^
s459933351
p00009
C++
##include<cstdio> #include<math.h> using namespace std; int A[1000000]; int Eratosthenes(int n) { int mama = 0; for (int i = 0; i < n; i++) { A[i] = 1; } for (int i = 2; i < sqrt(n); i++) { if (A[i]) { for (int j = 0; i*(j + 2) < n; j++) { A[i*(j + 2)] = 0; } } } for (int i = 2; i < n; i++) { if (A[i]) { mama++; } } return mama; } int main() { int n; while ((scanf("%d",&n))!= -1) { printf("%d\n", Eratosthenes(n+1)); } return 0; }
a.cc:1:1: error: stray '##' in program 1 | ##include<cstdio> | ^~ a.cc:1:3: error: 'include' does not name a type 1 | ##include<cstdio> | ^~~~~~~ In file included from /usr/include/c++/14/cmath:45, from /usr/include/c++/14/math.h:36, from a.cc:2: /usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity 164 | __is_null_pointer(std::nullptr_t) | ^ /usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)' 159 | __is_null_pointer(_Type) | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std' 164 | __is_null_pointer(std::nullptr_t) | ^~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/bits/specfun.h:43, from /usr/include/c++/14/cmath:3906: /usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std' 666 | struct is_null_pointer<std::nullptr_t> | ^~~~~~~~~ /usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid 666 | struct is_null_pointer<std::nullptr_t> | ^ /usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid 670 | struct is_null_pointer<const std::nullptr_t> | ^ /usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid 674 | struct is_null_pointer<volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid 678 | struct is_null_pointer<const volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ In file included from /usr/include/stdlib.h:32, from /usr/include/c++/14/bits/std_abs.h:38, from /usr/include/c++/14/cmath:49: /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^ /usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid 1438 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared 1440 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope 1441 | struct rank<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid 1441 | struct rank<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared 2086 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope 2087 | struct remove_extent<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid 2087 | struct remove_extent<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared 2099 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope 2100 | struct remove_all_extents<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid 2100 | struct remove_all_extents<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared 2171 | template<std::size_t _Len> | ^~~ /usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope 2176 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^~~~ /usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^ /usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope 2202 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope 2203 | struct __attribute__((__aligned__((_Align)))) { } __align; | ^~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:65: /usr/include/c++/14/bits/stl_iterator_base_types.h:125:67: error: 'ptrdiff_t' does not name a type 125 | template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t, | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_types.h:1:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' +++ |+#include <cstddef> 1 | // Types used in iterator implementation -*- C++ -*- /usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: error: 'ptrdiff_t' does not name a type 214 | typedef ptrdiff_t difference_type; | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: error: 'ptrdiff_t' does not name a type 225 | typedef ptrdiff_t difference_type; | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' In file included from /usr/include/c++/14/bits/stl_algobase.h:66: /usr/include/c++/14/bits/stl_iterator_base_funcs.h:112:5: error: 'ptrdiff_t' does not name a type 112 | ptrdiff_t | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:66:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 65 | #include <debug/assertions.h> +++ |+#include <cstddef> 66 | #include <bits/stl_iterator_base_types.h> /usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: error: 'ptrdiff_t' does not name a type 118 | ptrdiff_t | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' In file included from /us
s181428783
p00009
C++
import sys def prime(x): for i in p_list: if x % i == 0: return 0 return 1 if __name__ == "__main__": a = 10000 i = 2 p_list = [] while i < a: if prime(i): p_list.append(i) i += 1 print(p_list) for i in sys.stdin: n = int(i) while 1: if n not in p_list: n -= 1 else: print(p_list.index(n) + 1)
a.cc:1:1: error: 'import' does not name a type 1 | import sys | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
s612656576
p00009
C++
#include <iostream> #include <algorithm> #include <vector> typedef int TInt; typedef std::vector<TInt> TList; bool IsPrime(TInt Value, const TList& Prime) { TInt Max = std::sqrt(Value); for(TList::const_iterator It = Prime.begin(); It != Prime.end() && *It <= Max; ++It) { if(Value % (*It) == 0) return false; } return true; } TList GetPrimeList(TInt Max) { TList Prime; Prime.reserve(Max); Prime.push_back(2); for(TInt i = 3; i <= Max; i += 2){ if(IsPrime(i, Prime)){ Prime.push_back(i); } } return Prime; } int main() { TList List = GetPrimeList(999999); while(true){ int n; std::cin >> n; if(std::cin.eof()) break; TList::iterator It = std::upper_bound(List.begin(), List.end(), n); std::cout << std::distance(List.begin(), It) << std::endl; } return 0; }
a.cc: In function 'bool IsPrime(TInt, const TList&)': a.cc:9:21: error: 'sqrt' is not a member of 'std'; did you mean 'sort'? 9 | TInt Max = std::sqrt(Value); | ^~~~ | sort
s464590314
p00009
C++
<?php $max=1000000; $maxR=floor(sqrt($max)); $ch=[0,0,1,1]; for($i=4;$i<$max;$i+=2){$ch[]=0;$ch[]=1;} for($i=3;$i<$maxR;$i+=2) if($ch[$i]) for($j=$i+$i;$j<$max;$j+=$i) $ch[$j]=0; for($i=3;$i<$max;$i++) $ch[$i]+=$ch[$i-1]; while(fscanf(STDIN,"%d",$n)) printf("%d\n",$ch[$n]);
a.cc:1:1: error: expected unqualified-id before '<' token 1 | <?php | ^ a.cc:3:1: error: '$maxR' does not name a type 3 | $maxR=floor(sqrt($max)); | ^~~~~ a.cc:5:1: error: '$ch' does not name a type 5 | $ch=[0,0,1,1]; | ^~~ a.cc:7:1: error: expected unqualified-id before 'for' 7 | for($i=4;$i<$max;$i+=2){$ch[]=0;$ch[]=1;} | ^~~ a.cc:7:10: error: '$i' does not name a type 7 | for($i=4;$i<$max;$i+=2){$ch[]=0;$ch[]=1;} | ^~ a.cc:7:18: error: '$i' does not name a type 7 | for($i=4;$i<$max;$i+=2){$ch[]=0;$ch[]=1;} | ^~ a.cc:9:1: error: expected unqualified-id before 'for' 9 | for($i=3;$i<$maxR;$i+=2) if($ch[$i]) for($j=$i+$i;$j<$max;$j+=$i) $ch[$j]=0; | ^~~ a.cc:9:10: error: '$i' does not name a type 9 | for($i=3;$i<$maxR;$i+=2) if($ch[$i]) for($j=$i+$i;$j<$max;$j+=$i) $ch[$j]=0; | ^~ a.cc:9:19: error: '$i' does not name a type 9 | for($i=3;$i<$maxR;$i+=2) if($ch[$i]) for($j=$i+$i;$j<$max;$j+=$i) $ch[$j]=0; | ^~ a.cc:9:51: error: '$j' does not name a type 9 | for($i=3;$i<$maxR;$i+=2) if($ch[$i]) for($j=$i+$i;$j<$max;$j+=$i) $ch[$j]=0; | ^~ a.cc:9:59: error: '$j' does not name a type 9 | for($i=3;$i<$maxR;$i+=2) if($ch[$i]) for($j=$i+$i;$j<$max;$j+=$i) $ch[$j]=0; | ^~ a.cc:11:1: error: expected unqualified-id before 'for' 11 | for($i=3;$i<$max;$i++) $ch[$i]+=$ch[$i-1]; | ^~~ a.cc:11:10: error: '$i' does not name a type 11 | for($i=3;$i<$max;$i++) $ch[$i]+=$ch[$i-1]; | ^~ a.cc:11:18: error: '$i' does not name a type 11 | for($i=3;$i<$max;$i++) $ch[$i]+=$ch[$i-1]; | ^~ a.cc:13:1: error: expected unqualified-id before 'while' 13 | while(fscanf(STDIN,"%d",$n)) printf("%d\n",$ch[$n]); | ^~~~~
s077875352
p00009
C++
<?php $max=1000000; $maxR=floor(sqrt($max)); $ch=[0,0,1,1]; for($i=4;$i<$max;$i+=2){ $ch[]=0;$ch[]=1; } for($i=3;$i<$maxR;$i+=2){ if($ch[$i]){ for($j=$i+$i;$j<$max;$j+=$i){ $ch[$j]=0; } } } for($i=3;$i<$max;$i++){ $ch[$i]+=$ch[$i-1]; } while(fscanf(STDIN,"%d",$n)){ printf("%d\n",$ch[$n]); }
a.cc:1:1: error: expected unqualified-id before '<' token 1 | <?php | ^ a.cc:3:1: error: '$maxR' does not name a type 3 | $maxR=floor(sqrt($max)); | ^~~~~ a.cc:5:1: error: '$ch' does not name a type 5 | $ch=[0,0,1,1]; | ^~~ a.cc:7:1: error: expected unqualified-id before 'for' 7 | for($i=4;$i<$max;$i+=2){ | ^~~ a.cc:7:10: error: '$i' does not name a type 7 | for($i=4;$i<$max;$i+=2){ | ^~ a.cc:7:18: error: '$i' does not name a type 7 | for($i=4;$i<$max;$i+=2){ | ^~ a.cc:11:1: error: expected unqualified-id before 'for' 11 | for($i=3;$i<$maxR;$i+=2){ | ^~~ a.cc:11:10: error: '$i' does not name a type 11 | for($i=3;$i<$maxR;$i+=2){ | ^~ a.cc:11:19: error: '$i' does not name a type 11 | for($i=3;$i<$maxR;$i+=2){ | ^~ a.cc:19:1: error: expected unqualified-id before 'for' 19 | for($i=3;$i<$max;$i++){ | ^~~ a.cc:19:10: error: '$i' does not name a type 19 | for($i=3;$i<$max;$i++){ | ^~ a.cc:19:18: error: '$i' does not name a type 19 | for($i=3;$i<$max;$i++){ | ^~ a.cc:23:1: error: expected unqualified-id before 'while' 23 | while(fscanf(STDIN,"%d",$n)){ | ^~~~~
s775361177
p00009
C++
#include <iostream> int main(){ int i,j,ch[1000000]; for(i=0;i<1000000;i+=2){ch[i]=0;ch[i+1]=1;} ch[1]=0; ch[2]=1; for(i=3;i<1000;i+=2) if(ch[i]) for(j=i<<1;j<1000000;j+=i) ch[j]=0; for(i=3;i<1000000;i++) ch[i]+=ch[i-1]; while(cin>>i) cout<<ch[i]<<endl; return 0; }
a.cc: In function 'int main()': a.cc:14:11: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 14 | while(cin>>i) cout<<ch[i]<<endl; | ^~~ | std::cin In file included from a.cc:1: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:14:19: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 14 | while(cin>>i) cout<<ch[i]<<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:14:32: error: 'endl' was not declared in this scope; did you mean 'std::endl'? 14 | while(cin>>i) cout<<ch[i]<<endl; | ^~~~ | std::endl In file included from /usr/include/c++/14/iostream:41: /usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here 744 | endl(basic_ostream<_CharT, _Traits>& __os) | ^~~~
s723250047
p00009
C++
#include <iostream> #define _USE_MATH_DEFINES #include <math.h> #define MAX_N 100000 void q9() { bool IsPrime[MAX_N]; memset(IsPrime, 1, sizeof(IsPrime)); IsPrime[0] = false; IsPrime[1] = false; for (int i = 0; i < sqrt(MAX_N); i++) { if (!IsPrime[i]) continue; for (int j = i * 2; j < MAX_N; j += i) { IsPrime[j] = false; } } int NofP[MAX_N]; NofP[0] = 0; for (int i = 1; i < MAX_N; i++) { NofP[i] = NofP[i - 1] + IsPrime[i]; } int n; for (; cin >> n;) { cout << NofP[n] << endl; } } int main() { q9(); return 0; }
a.cc: In function 'void q9()': a.cc:8:9: error: 'memset' was not declared in this scope 8 | memset(IsPrime, 1, sizeof(IsPrime)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include <math.h> +++ |+#include <cstring> 4 | #define MAX_N 100000 a.cc:25:16: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 25 | for (; cin >> n;) { | ^~~ | std::cin In file included from a.cc:1: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:26:17: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 26 | cout << NofP[n] << 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:36: error: 'endl' was not declared in this scope; did you mean 'std::endl'? 26 | cout << NofP[n] << endl; | ^~~~ | std::endl In file included from /usr/include/c++/14/iostream:41: /usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here 744 | endl(basic_ostream<_CharT, _Traits>& __os) | ^~~~
s542870673
p00009
C++
#include <iostream> #include <string.h> #define _USE_MATH_DEFINES #include <math.h> #define MAX_N 100000 void q9() { bool IsPrime[MAX_N]; memset(IsPrime, 1, sizeof(IsPrime)); IsPrime[0] = false; IsPrime[1] = false; for (int i = 0; i < sqrt(MAX_N); i++) { if (!IsPrime[i]) continue; for (int j = i * 2; j < MAX_N; j += i) { IsPrime[j] = false; } } int NofP[MAX_N]; NofP[0] = 0; for (int i = 1; i < MAX_N; i++) { NofP[i] = NofP[i - 1] + IsPrime[i]; } int n; for (; cin >> n;) { cout << NofP[n] << endl; } } int main() { q9(); return 0; }
a.cc: In function 'void q9()': a.cc:26:16: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 26 | for (; cin >> n;) { | ^~~ | std::cin In file included from a.cc:1: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:27:17: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 27 | cout << NofP[n] << 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:27:36: error: 'endl' was not declared in this scope; did you mean 'std::endl'? 27 | cout << NofP[n] << endl; | ^~~~ | std::endl In file included from /usr/include/c++/14/iostream:41: /usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here 744 | endl(basic_ostream<_CharT, _Traits>& __os) | ^~~~
s026403498
p00009
C++
import sys import math as mas def sieve(n): p=[True for i in range(n+1)] p[0]=p[1]=False end=int(n**0.5) for i in range(2,end+1): if p[i]: for j in range(i*i,n+1,i): p[j]=False return p sosu=sieve(1000010) for i in sys.stdin: t=int(i) if t<2:print(0) elif t==2:print(1) else:print(1+sum(sosu[t] for t in range(3,int(i)+1,2))) # a,b=map(int,i.split()) # print(gcd(a,b),lcm(a,b))
a.cc:21:9: error: invalid preprocessing directive #a 21 | # a,b=map(int,i.split()) | ^ a.cc:22:9: error: invalid preprocessing directive #print 22 | # print(gcd(a,b),lcm(a,b)) | ^~~~~ a.cc:1:1: error: 'import' does not name a type 1 | import sys | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
s569574723
p00009
C++
#include <iostream> #include <cmath> int prime[1000000]; bool isPrime(int n) { int x = sqrt(static_cast<double>n); for (int i = 3; i <= x; i += 2) { if (n % i == 0) { return false; } } return true; } void get_prime(int max_num) { int primecount = 1; prime[2] = primecount; for (int i = 3; i <= max_num; i += 2) { if (isPrime(i)) prime[i] = ++primecount; else prime[i] = primecount; } } int main () { int ns[31]; int i = 0, max_num; while (std::cin >> ns[i]) { max_num = std::max(max_num, ns[i]); if (ns[i] % 2 == 0) ns[i] --; i ++; } get_prime(max_num); for (int j = 0; j < i; j ++) { std::cout << prime[ns[j]] << std::endl; } return 0; }
a.cc: In function 'bool isPrime(int)': a.cc:8:35: error: expected '(' before 'n' 8 | int x = sqrt(static_cast<double>n); | ^ | ( a.cc:8:37: error: expected ')' before ';' token 8 | int x = sqrt(static_cast<double>n); | ~ ^ | )
s504637497
p00009
C++
#include <stdio.h> int main() { int low, high, i, flag,c=0,s; while(scanf("%d",&high)==!EOF) { int start = 2; while (start <= high) { flag = 0; s = sqrt(start); for(i = 2; i <= start/2; i++) { if(start % i == 0) { flag = 1; break; } } if (flag == 0) { c++; } start++; } printf("%d\n",c); c=0; } return 0; }
a.cc: In function 'int main()': a.cc:12:21: error: 'sqrt' was not declared in this scope 12 | s = sqrt(start); | ^~~~
s012077502
p00009
C++
#include<bits/stdc++.h> int main() { long long int low, high, i, flag,c, s ; while(scanf("%lld", &high)!=EOF){ long long int start = 2; c = 0; while (start <= high) { flag = 0; s = sqrt(start); for(i = 2; i <= s; i++) { if(start% i == 0) { flag = 1; break; } } if (flag == 0) { c++; } start++; } printf("%lld\n",c); }
a.cc: In function 'int main()': a.cc:33:6: error: expected '}' at end of input 33 | } | ^ a.cc:3:1: note: to match this '{' 3 | { | ^
s602556539
p00009
C++
#include<iostream> using namespace std; int main(int argv,int* argv[]){ unsigned x[30]; int count=0; for(int i=0;i<argv;i++){ cin>>x[i]; } for(int i=0;i<argv;i++){ for(int j=1;j<x[i];j++){ if(x[i]%j!=0) count++; } cout<<count<<endl; count=0; } return 0; }
a.cc:3:24: error: conflicting declaration 'int** argv' 3 | int main(int argv,int* argv[]){ | ~~~~~^~~~~~ a.cc:3:14: note: previous declaration as 'int argv' 3 | int main(int argv,int* argv[]){ | ~~~~^~~~
s338157897
p00009
C++
#include<iostream> using namespace std; int main(int argv,char* argv[]){ unsigned x[30]; int count=0; for(int i=0;i<argv;I++){ cin>>x[i]; } for(int i=0;i<argv;i++){ for(int j=1;j<x[i];j++){ if(x[i]%j!=0) count++; } cout<<count<<endl; count=0; } return 0; }
a.cc:3:25: error: conflicting declaration 'char** argv' 3 | int main(int argv,char* argv[]){ | ~~~~~~^~~~~~ a.cc:3:14: note: previous declaration as 'int argv' 3 | int main(int argv,char* argv[]){ | ~~~~^~~~ a.cc: In function 'int main(...)': a.cc:6:20: error: 'I' was not declared in this scope 6 | for(int i=0;i<argv;I++){ | ^
s010511564
p00009
C++
#include<iostream> using namespace std; int main(int argc,char* argv[]){ unsigned x[30]; int count=0; for(int i=0;i<argc;I++){ cin>>x[i]; } for(int i=0;i<argc(i++){ for(int j=1;j<x[i];j++){ if(x[i]%j!=0) count++; } cout<<count<<endl; count=0; } return 0; }
a.cc: In function 'int main(int, char**)': a.cc:6:20: error: 'I' was not declared in this scope 6 | for(int i=0;i<argc;I++){ | ^ a.cc:9:19: error: 'argc' cannot be used as a function 9 | for(int i=0;i<argc(i++){ | ~~~~^~~~~ a.cc:9:24: error: expected ';' before '{' token 9 | for(int i=0;i<argc(i++){ | ^ | ; a.cc:9:24: error: expected primary-expression before '{' token a.cc:9:24: error: expected ')' before '{' token 9 | for(int i=0;i<argc(i++){ | ~ ^ | )
s783829158
p00009
C++
#include<iostream> #include<algorithm> #include<cstdio> using namespace std; int main(void){ int unti[1000002] = {0}; fill(unti,unti + 1000001;n++) { if(unti[n] == 0) { for(int a = 2;(a * n) < 1000001;a++) { if((a * n ) < 1000001 ) unti[a * n]++; } } } int b; for(int i;i <= 31;i++){ cin >> b int cnt = (count(unti,unti+b+1,0) - 2); cout << cnt << endl; } return 0; }
a.cc: In function 'int main()': a.cc:8:25: error: expected ')' before ';' token 8 | fill(unti,unti + 1000001;n++) | ~ ^ | ) a.cc:8:26: error: 'n' was not declared in this scope 8 | fill(unti,unti + 1000001;n++) | ^ a.cc:20:9: error: expected ';' before 'int' 20 | cin >> b | ^ | ; 21 | 22 | int cnt = (count(unti,unti+b+1,0) - 2); | ~~~ a.cc:23:9: error: 'cnt' was not declared in this scope; did you mean 'int'? 23 | cout << cnt << endl; | ^~~ | int
s286554401
p00009
C++
#include<iostream> #include<stdio.h> #include<windows.h> #include<conio.h> #include<String> #include<time.h> #include<math.h> using namespace std; int main() { int c = 0; int i = 1; unsigned long long a = 0; unsigned long long b = 0; unsigned long long sosuu[100000] = { 0 }; char fire = 0; int pattara = 0; cin >> c; cout << 2; /*while(i>-1)*/for(int i=0;i<c;i++){ /*for (int z = 0; z < a;z++){*/ for (int q = 1; q <= sqrt(i); q++) { sosuu[pattara] = i; if (sosuu[pattara] % 2 == 0) { break; } if (sosuu[pattara] % q == 0) { b += 1; } } /*if (b == 1) { fire = _getch(); pattara++; cout << sosuu[pattara - 1] << " " << pattara << endl; }*/ b = 0; /*i++;*/ if (pattara == c){ break; } } cout << pattara << endl; /*system("pause"); return 0;*/ }
a.cc:3:9: fatal error: windows.h: No such file or directory 3 | #include<windows.h> | ^~~~~~~~~~~ compilation terminated.
s818929327
p00009
C++
import java.util.*; class Prime2 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int[] x = new int[30]; int t=0,j,count=0; while(scan.hasNextInt()){ count = 0; int lim = scan.nextInt(); int ptr = 0; //?????????????´???°?????° int[] prime = new int[500000]; //?´???°???????´????????????? if(lim >= 2){ prime[ptr++] = 2; count++; } if(lim >= 3){ prime[ptr++] = 3; count++; } for (int n = 5; n <= lim; n += 2) { boolean wflag = false; for (int i = 1; prime[i] * prime[i] <= n; i++) { if (0 == n % prime[i]) { wflag = true; break; } } if (!wflag) { prime[ptr++] = n; count++; } } x[t] = count; t++; } for (int i : x) System.out.println(i); } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.util.*; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:11: error: expected ':' before 'static' 4 | public static void main(String[] args) { | ^~~~~~~ | : a.cc:4:29: error: 'String' has not been declared 4 | public static void main(String[] args) { | ^~~~~~ a.cc:4:38: error: expected ',' or '...' before 'args' 4 | public static void main(String[] args) { | ^~~~ a.cc:47:2: error: expected ';' after class definition 47 | } | ^ | ; a.cc: In static member function 'static void Prime2::main(int*)': a.cc:6:9: error: 'Scanner' was not declared in this scope 6 | Scanner scan = new Scanner(System.in); | ^~~~~~~ a.cc:7:12: error: structured binding declaration cannot have type 'int' 7 | int[] x = new int[30]; | ^~ a.cc:7:12: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:7:12: error: empty structured binding declaration a.cc:7:15: error: expected initializer before 'x' 7 | int[] x = new int[30]; | ^ a.cc:11:15: error: 'scan' was not declared in this scope 11 | while(scan.hasNextInt()){ | ^~~~ a.cc:15:20: error: structured binding declaration cannot have type 'int' 15 | int[] prime = new int[500000]; //?´???°???????´????????????? | ^~ a.cc:15:20: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:15:20: error: empty structured binding declaration a.cc:15:23: error: expected initializer before 'prime' 15 | int[] prime = new int[500000]; //?´???°???????´????????????? | ^~~~~ a.cc:18:25: error: 'prime' was not declared in this scope; did you mean 'Prime2'? 18 | prime[ptr++] = 2; | ^~~~~ | Prime2 a.cc:22:33: error: 'prime' was not declared in this scope; did you mean 'Prime2'? 22 | prime[ptr++] = 3; | ^~~~~ | Prime2 a.cc:27:21: error: 'boolean' was not declared in this scope; did you mean 'bool'? 27 | boolean wflag = false; | ^~~~~~~ | bool a.cc:28:37: error: 'prime' was not declared in this scope; did you mean 'Prime2'? 28 | for (int i = 1; prime[i] * prime[i] <= n; i++) { | ^~~~~ | Prime2 a.cc:31:25: error: 'wflag' was not declared in this scope 31 | wflag = true; | ^~~~~ a.cc:35:22: error: 'wflag' was not declared in this scope 35 | if (!wflag) { | ^~~~~ a.cc:36:25: error: 'prime' was not declared in this scope; did you mean 'Prime2'? 36 | prime[ptr++] = n; | ^~~~~ | Prime2 a.cc:40:17: error: 'x' was not declared in this scope 40 | x[t] = count; | ^ a.cc:44:30: error: 'x' was not declared in this scope 44 | for (int i : x) | ^ a.cc:45:17: error: 'System' was not declared in this scope 45 | System.out.println(i); | ^~~~~~
s411401507
p00009
C++
#include<iostream> #include<vector> using namespace std; #define MAX 1000000 int main(void){ int n; cin >> n; int num = 0; vector<long int> array(MAX,0); array[0] = 2; count++; array[1] = 3; count++; for(int i = 5 i < n ; i+=2){ int flag = 0; for(int j = 0; array[j]*array[j] <= n;j++){ if(n % array[i] == 0){ flag = 1; break; } } if(!flag){ count++; } } cout << count << endl; return 0; }
a.cc: In function 'int main()': a.cc:16:17: error: 'count' was not declared in this scope 16 | array[0] = 2; count++; | ^~~~~ a.cc:19:16: error: expected ';' before 'i' 19 | for(int i = 5 i < n ; i+=2){ | ^~ | ;
s688827445
p00009
C++
import math def isPrime(n): if n==1: return False if n==2: return True for i in range(2,int(math.sqrt(n))+2): if n%i==0: return False return True while True: a = input() if a=='EOF': break sum = 0 for i in range(1,a+1): if isPrime(i)==True: sum+=1 print sum
a.cc:12:15: warning: multi-character character constant [-Wmultichar] 12 | if a=='EOF': break | ^~~~~ 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'
s248419466
p00009
C++
#coding:utf-8 import time import math import numpy as np def flatten(L): if isinstance(L, list): if L == []: return [] else: return flatten(L[0]) + flatten(L[1:]) else: return [L] def Eratos(data): p_list = [] # ???????????? tmp = [] num = int(math.sqrt(len(data)))+1 for i in data: i=data[0] if i>num: break else: p_list.append(i) for j in data: if j%i == 0: data.remove(j) p_list.append(data) return p_list x = int(input()) r_list = list(range(2,(x+1))) ans = [] ans = Eratos(r_list) print("prime numbers is ") print(len(flatten(ans)))
a.cc:1:2: error: invalid preprocessing directive #coding 1 | #coding:utf-8 | ^~~~~~ a.cc:17:17: error: stray '#' in program 17 | p_list = [] # ???????????? | ^ a.cc:2:1: error: 'import' does not name a type 2 | import time | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
s779684429
p00009
C++
#include<iostream> #include<stdio.h> #include<windows.h> #include<conio.h> #include<String> #include<time.h> #include<math.h> using namespace std; int c = 0; int i = 1; unsigned long long a = 0; unsigned long long b = 0; unsigned long long sosuu[100000] = { 0 }; char fire = 0; int pattara = 0; int sub(int c) { /*while(i>-1)*/ for (int i = 2; i<=c; i++){ /*for (int z = 0; z < a;z++){*/ for (int q = 1; q <= sqrt(i); q++) { sosuu[pattara] = i; if (sosuu[pattara] % 2 == 0 && sosuu[pattara]!= 2) { break; } if (sosuu[pattara] % q == 0) { b += 1; } } if (b == 1) { /*fire = _getch();*/ pattara++; } b = 0; /*i++;*/ } return 0; } int main(){ while (scanf("%d", &c) != EOF){ sub(c); cout << pattara << endl; pattara = 0; } }
a.cc:3:9: fatal error: windows.h: No such file or directory 3 | #include<windows.h> | ^~~~~~~~~~~ compilation terminated.
s144591019
p00009
C++
#include<iostream> #include<stdio.h> #include<windows.h> #include<conio.h> #include<String> #include<time.h> #include<math.h> using namespace std; int c = 0; int i = 1; unsigned long long a = 0; unsigned long long b = 0; unsigned long long sosuu[100000] = { 0 }; char fire = 0; int pattara = 0; int sub(int c) { /*while(i>-1)*/ for (int i = 2; i<=c; i++){ /*for (int z = 0; z < a;z++){*/ for (int q = 1; q <= sqrt(i); q++) { sosuu[pattara] = i; if (sosuu[pattara] % 2 == 0 && sosuu[pattara]!= 2) { break; } if (sosuu[pattara] % q == 0) { b += 1; } } if (b == 1) { /*fire = _getch();*/ pattara++; } b = 0; /*i++;*/ } return 0; } int main(){ while (scanf("%d", &c) != EOF){ sub(c); cout << pattara << endl; pattara = 0; } return 0; }
a.cc:3:9: fatal error: windows.h: No such file or directory 3 | #include<windows.h> | ^~~~~~~~~~~ compilation terminated.
s795175989
p00009
C++
#include<iostream> #include<stdio.h> #include<windows.h> #include<conio.h> #include<String> #include<time.h> #include<math.h> using namespace std; int c = 0; int i = 1; unsigned long long a = 0; unsigned long long b = 0; unsigned long long sosuu[100000] = { 0 }; char fire = 0; int pattara = 0; int sub(int c) { for (int i = 2; i<=c; i++){ for (int q = 1; q <= sqrt(i); q++) { sosuu[pattara] = i; if (sosuu[pattara] % 2 == 0 && sosuu[pattara]!= 2) { break; } if (sosuu[pattara] % q == 0) { b += 1; } } if (b == 1) { pattara++; } b = 0; } return 0; } int main(){ while (scanf("%d", &c) != EOF){ sub(c); cout << pattara << endl; pattara = 0; } return 0; }
a.cc:3:9: fatal error: windows.h: No such file or directory 3 | #include<windows.h> | ^~~~~~~~~~~ compilation terminated.
s596053702
p00009
C++
#include<stdio.h> int main(void) { int n,i,j,z,x; scanf("%d",&n); for(n!=1){ for(i=2;i<=n;i++){ z=0; for(j=2;j<=i;j++){ if(i%j==0 && i!=j){ z++; break; } } if(z==0){ x++; } } printf("%d\n",x); scanf("%d",&n); } return 0; }
a.cc: In function 'int main()': a.cc:7:17: error: expected ';' before ')' token 7 | for(n!=1){ | ^ | ; a.cc:23:9: error: expected primary-expression before 'return' 23 | return 0; | ^~~~~~ a.cc:22:10: error: expected ';' before 'return' 22 | } | ^ | ; 23 | return 0; | ~~~~~~ a.cc:23:9: error: expected primary-expression before 'return' 23 | return 0; | ^~~~~~ a.cc:22:10: error: expected ')' before 'return' 22 | } | ^ | ) 23 | return 0; | ~~~~~~ a.cc:7:12: note: to match this '(' 7 | for(n!=1){ | ^
s198457727
p00009
C++
#include<stdio.h> int main(void) { int n,i,j,z,x; scanf("%d",&n); for(n!=1){ for(i=2;i<=n;i++){ z=0; for(j=2;j<=i;j++){ if(i%j==0 && i!=j){ z++; break; } } if(z==0){ x++; } } printf("%d\n",x); scanf("%d",&n); } return 0; }
a.cc: In function 'int main()': a.cc:7:17: error: expected ';' before ')' token 7 | for(n!=1){ | ^ | ; a.cc:23:9: error: expected primary-expression before 'return' 23 | return 0; | ^~~~~~ a.cc:22:10: error: expected ';' before 'return' 22 | } | ^ | ; 23 | return 0; | ~~~~~~ a.cc:23:9: error: expected primary-expression before 'return' 23 | return 0; | ^~~~~~ a.cc:22:10: error: expected ')' before 'return' 22 | } | ^ | ) 23 | return 0; | ~~~~~~ a.cc:7:12: note: to match this '(' 7 | for(n!=1){ | ^
s760584052
p00009
C++
#include<iostream> using namespace std; int main() { bool is_prime[100000]: is_prime[0]=is_prime[1]=false; for(int i=2;i<1000000;i<i++){ is_prime[i]=true; } for(int i=2;i*i<1000000;i++){ if(is_prime[i]){ for(int j=i*i;j<1000000;j+=i){ is_primej]=false; } } } int n_prime[1000000]; int cnt=0; for(int i=0;i<1000000;i++){ if(is_prime[i]){ cnt++; } n_prime[i]=cnt; } while(true){ int n; cin>>n; if(cin.eof()) break; cout<<n_prime[n]<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:6:30: error: expected initializer before ':' token 6 | bool is_prime[100000]: | ^ a.cc:10:17: error: 'is_prime' was not declared in this scope 10 | is_prime[i]=true; | ^~~~~~~~ a.cc:14:20: error: 'is_prime' was not declared in this scope 14 | if(is_prime[i]){ | ^~~~~~~~ a.cc:16:33: error: 'is_primej' was not declared in this scope 16 | is_primej]=false; | ^~~~~~~~~ a.cc:25:20: error: 'is_prime' was not declared in this scope; did you mean 'n_prime'? 25 | if(is_prime[i]){ | ^~~~~~~~ | n_prime
s014940614
p00009
C++
include <bits/stdc++.h> using namespace std; static const long MAX = 1000000L; int main() { vector<long> prime; bool isPrime; long n; long i, len = sqrt(MAX) + 1; long j, lenJ; long k; prime.push_back(2); for (i = 3; i <= len; i += 2) { isPrime = true; lenJ = prime.size(); k = sqrt(i) + 1; for (j = 0; j < lenJ; j++) { if (k <= prime[j]) break; if (i % prime[j] == 0) { isPrime = false; break; } if (isPrime) prime.push_back(i); } lenJ = prime.size(); while (cin >> n) { counter = 1; if (n < 2) counter = 0; for (i = 3; i <= n; i += 2) { isPrime = true; k = sqrt(i) + 1; for (j = 0; j < lenJ; j++) { if (k <= prime[j]) break; if (i % prime[j] == 0) { isPrime = false; break; } } if (isPrime) counter++; } cout << counter << endl; } return 0; }
a.cc:1:1: error: 'include' does not name a type 1 | include <bits/stdc++.h> | ^~~~~~~ a.cc: In function 'int main()': a.cc:8:5: error: 'vector' was not declared in this scope 8 | vector<long> prime; | ^~~~~~ a.cc:8:12: error: expected primary-expression before 'long' 8 | vector<long> prime; | ^~~~ a.cc:12:19: error: 'sqrt' was not declared in this scope 12 | long i, len = sqrt(MAX) + 1; | ^~~~ a.cc:16:5: error: 'prime' was not declared in this scope; did you mean 'isPrime'? 16 | prime.push_back(2); | ^~~~~ | isPrime a.cc:36:12: error: 'cin' was not declared in this scope 36 | while (cin >> n) { | ^~~ a.cc:37:9: error: 'counter' was not declared in this scope 37 | counter = 1; | ^~~~~~~ a.cc:58:9: error: 'cout' was not declared in this scope 58 | cout << counter << endl; | ^~~~ a.cc:58:28: error: 'endl' was not declared in this scope 58 | cout << counter << endl; | ^~~~ a.cc:62:2: error: expected '}' at end of input 62 | } | ^ a.cc:7:12: note: to match this '{' 7 | int main() { | ^