submission_id
stringlengths 10
10
| problem_id
stringlengths 6
6
| language
stringclasses 3
values | code
stringlengths 1
522k
| compiler_output
stringlengths 43
10.2k
|
|---|---|---|---|---|
s782226098
|
p00009
|
C++
|
#include<iostream>
using namespace std;
int main()
{
int n,S;
while(cin>>n)
{
S=0;
if(n==1)
{
cout<<0<<endl;
}
else if(n>=2)
{
S++;
}
else if
{
for(int i=2;i<=n;i++)
{
for(int j=i-1;j>1;j--)
{
if(i%j==0)
{
break;
}
if(j==2)
{
S++;
}
}
}
cout<<S<<endl;
}
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:18:9: error: expected '(' before '{' token
18 | {
| ^
| (
|
s332328371
|
p00009
|
C++
|
#include<iostream>
using namespace std;
int main(){
int N,count=0;
cin >> N
for(int x=2;x<=N;x++){
int flag = 0;
for(int y=2;y<x;y++){
if((x%y)==0) flag = 1;
}
if(flag == 0) count++;
}
cout << count << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:5:17: error: expected ';' before 'for'
5 | cin >> N
| ^
| ;
6 | for(int x=2;x<=N;x++){
| ~~~
a.cc:6:21: error: 'x' was not declared in this scope
6 | for(int x=2;x<=N;x++){
| ^
|
s709272096
|
p00009
|
C++
|
#include<iostream>
using namespace std;
int main(k<30){
int N,count=0,k;
while(){
cin >> N;
count = 0;
if(N<0) break;
for(int x=2;x<=N;x++){
int flag = 0;
for(int y=2;y<x;y++){
if((x%y)==0) flag = 1;
}
if(flag == 0) count++;
}
cout << count << endl;
k++;
}
return 0;
}
|
a.cc:3:5: error: cannot declare '::main' to be a global variable
3 | int main(k<30){
| ^~~~
a.cc:3:10: error: 'k' was not declared in this scope
3 | int main(k<30){
| ^
|
s336230994
|
p00009
|
C++
|
#include<iostream>
using namespace std;
int main(){
long long int N,count[1000000];
count[1] = 1;
if(N<0) break;
for(int x=2;x<=1000000;x++){
int flag = 0;
for(int y=2;y<x;y++){
if((x%y)==0) flag = 1;
}
if(flag == 0) count[i] = count[i-1]+1;
}
while(cin >> N){
cout << count[N] << endl;
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:6:25: error: break statement not within loop or switch
6 | if(N<0) break;
| ^~~~~
a.cc:12:39: error: 'i' was not declared in this scope
12 | if(flag == 0) count[i] = count[i-1]+1;
| ^
|
s319020366
|
p00009
|
C++
|
#include<iostream>
using namespace std;
int main(){
long long int N,count[1000000];
count[1] = 1;
for(int x=2;x<=1000000;x++){
int flag = 0;
for(int y=2;y<x;y++){
if((x%y)==0) flag = 1;
}
if(flag == 0) count[i] = count[i-1]+1;
}
while(cin >> N){
cout << count[N] << endl;
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:11:39: error: 'i' was not declared in this scope
11 | if(flag == 0) count[i] = count[i-1]+1;
| ^
|
s306848553
|
p00009
|
C++
|
import math
def check_prime(goal):
true_or_false=False
for i in range(2,int(math.sqrt(goal))+1):
if goal%i==0:
true_or_false=True
if true_or_false==False:
return True
else:
return False
anss=[]
while True:
try:
num=int(input())
num_of_prime=0
for i in range(2,num+1):
if check_prime(i):
num_of_prime+=1
anss.append(num_of_prime)
except:
break
for ans in anss:
print(ans)
|
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'
|
s653269757
|
p00009
|
C++
|
#include<iostream>
using namespace std;
int Era(int N) {
int prime_num = 0;
int* array = new int[N + 1];
for (int i = 2; i < N + 1; i++) {
array[i] = 1;
}
for (int i = 2; i <= sqrt(N); i++) {
if (array[i]) {
for (int j = 0; i*(j + 2) <= N; j++) {
array[i*(j + 2)] = 0;
}
}
}
for (int i = 2; i < N + 1; i++) {
if (array[i])prime_num++;
}
return prime_num;
}
int main() {
int num;
while (cin >> num) {
cout << Era(num) << endl;
}
return 0;
}
|
a.cc: In function 'int Era(int)':
a.cc:10:30: error: 'sqrt' was not declared in this scope
10 | for (int i = 2; i <= sqrt(N); i++) {
| ^~~~
|
s173624610
|
p00009
|
C++
|
#include<iostream>
using namespace std;
int Era(int N) {
int prime_num = 0;
int* array = new int[N + 1];
for (int i = 2; i < N + 1; i++) {
array[i] = 1;
}
for (int i = 2; i < sqrt(N); i++) {
if (array[i]) {
for (int j = 0; i*(j + 2) <= N; j++) {
array[i*(j + 2)] = 0;
}
}
}
for (int i = 2; i < N + 1; i++) {
if (array[i])prime_num++;
}
return prime_num;
}
int main() {
int num;
while (cin >> num) {
cout << Era(num) << endl;
}
return 0;
}
|
a.cc: In function 'int Era(int)':
a.cc:10:29: error: 'sqrt' was not declared in this scope
10 | for (int i = 2; i < sqrt(N); i++) {
| ^~~~
|
s101823226
|
p00009
|
C++
|
#include <iostream>
const bool isPrime(const int p)
{
if(p == 2)
{
return true;
}
if(p < 2 || p % 2 == 0)
{
return false;
}
for(int i = 3; i <= sqrt(p); i += 2)
{
if(p % i == 0)
{
return false;
}
}
return true;
}
int main(void)
{
bool p[1000000];
for(int i = 0; i < 1000000; ++i)
{
p[i] = isPrime(i);
}
int n;
while(std::cin >> n)
{
int result = 0;
for(int i = 0; i <= n; ++i)
{
result += p[i];
}
std::cout << result << std::endl;
}
return 0;
}
|
a.cc: In function 'const bool isPrime(int)':
a.cc:15:25: error: 'sqrt' was not declared in this scope
15 | for(int i = 3; i <= sqrt(p); i += 2)
| ^~~~
|
s062766136
|
p00009
|
C++
|
#include<stdio.h>
int main(void){
int s[10000], l, m, n, i, sum;
sum = 0;
for ( i = 1; i <= 1000000; i++ ) {
s[i] = 0;
}
for ( k = 2; k <= 1000000; k++ ){
if (s[k] == 0) {
for ( l = 2; l <= 100000 / k; l++ ) {
s[k * l] = 1;
}
}
}
while(scanf("%d", &n) != EOF){
for(i = 1; i <= n; i++){
if(s[i] == 0){
sum++;
}
}
}
printf("%d", sum);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:8:10: error: 'k' was not declared in this scope
8 | for ( k = 2; k <= 1000000; k++ ){
| ^
|
s305310616
|
p00009
|
C++
|
#include <iostream>
#include <cmath>
#include <time.h> // for clock()
using namespace std;
/*
1???2 ?????? n ?????§?????´??°???????????????
2??????????????£???????????°????????§???????°?????????????????????? p ??¨?????????????????????????????????????????°?????? p ??¨?????????
p ??\?????? p ????????°?????¨????¶????????????????
3???2??????????????°?????????????????????p ??? ???n ????¶??????????????????????????????????????????£?????????????´???°???
*/
// ??¨????????????????????????
int SieveOfEratosthenes(int num) {
if (num < 2) {
return 0;
}
// num???????´???°?????°
int count = 0;
bool fl[1000001];
memset(fl, true, sizeof(fl));
for (int i = 2; i <= sqrt(num); i++) {
if (fl[i]) {
for (int j = 2; j*i <= num; j++) {
fl[i*j] = false;
}
}
}
for (int i = 2; i <= num; i++) {
if (fl[i]) {
count++;
}
}
return count;
}
int main() {
int num = 0;
while (cin >> num) {
//clock_t start = clock(); // ??????????????????
cout << SieveOfEratosthenes(num) << endl;
//clock_t end = clock(); // ????????????
//std::cout << "duration = " << (double)(end - start) / CLOCKS_PER_SEC << "sec.\n";
}
return 0;
}
|
a.cc: In function 'int SieveOfEratosthenes(int)':
a.cc:21:9: error: 'memset' was not declared in this scope
21 | memset(fl, true, sizeof(fl));
| ^~~~~~
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 | #include <time.h> // for clock()
|
s083090323
|
p00009
|
C++
|
#include <iostream>
#include <cmath>
#include <cstdio>
#include <time.h> // for clock()
using namespace std;
/*
1???2 ?????? n ?????§?????´??°???????????????
2??????????????£???????????°????????§???????°?????????????????????? p ??¨?????????????????????????????????????????°?????? p ??¨?????????
p ??\?????? p ????????°?????¨????¶????????????????
3???2??????????????°?????????????????????p ??? ???n ????¶??????????????????????????????????????????£?????????????´???°???
*/
// ??¨????????????????????????
int SieveOfEratosthenes(int num) {
if (num < 2) {
return 0;
}
// num???????´???°?????°
int count = 0;
bool fl[1000001];
memset(fl, true, sizeof(fl));
for (int i = 2; i <= sqrt(num); i++) {
if (fl[i]) {
for (int j = 2; j*i <= num; j++) {
fl[i*j] = false;
}
}
}
for (int i = 2; i <= num; i++) {
if (fl[i]) {
count++;
}
}
return count;
}
int main() {
int num = 0;
while (cin >> num) {
//clock_t start = clock(); // ??????????????????
cout << SieveOfEratosthenes(num) << endl;
//clock_t end = clock(); // ????????????
//std::cout << "duration = " << (double)(end - start) / CLOCKS_PER_SEC << "sec.\n";
}
return 0;
}
|
a.cc: In function 'int SieveOfEratosthenes(int)':
a.cc:22:9: error: 'memset' was not declared in this scope
22 | memset(fl, true, sizeof(fl));
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include <cstdio>
+++ |+#include <cstring>
4 | #include <time.h> // for clock()
|
s179863932
|
p00009
|
C++
|
#include <iostream>
#include <cmath>
//#include <ctime>
#define Even(n) n%2
using namespace std;
void count_Prime(int n);
bool IsPrime(int num);
int main()
{
int Data = 0;
// clock_t start, end;
while (cin >> Data)
{
// start = clock();
count_Prime(Data);
// end = clock();
cout << (double)(end - start) / CLOCKS_PER_SEC << "sec" << endl;
}
return 0;
}
void count_Prime(int n)
{
int counter = 0, i = 0;
for (i = 2; i <= n; ++i)
{
if (IsPrime(i))
counter++;
}
cout << counter << endl;
}
bool IsPrime(int num)
{
if (num < 2) return false;
else if (num == 2) return true;
else if (num % 2 == 0) return false; // ??¶??°????????????????????????
double sqrtNum = sqrt(num);
for (int i = 3; i <= sqrtNum; i += 2)
{
if (num % i == 0)
{
// ?´???°??§?????????
return false;
}
}
// ?´???°??§??????
return true;
}
|
a.cc: In function 'int main()':
a.cc:21:40: error: 'start' was not declared in this scope
21 | cout << (double)(end - start) / CLOCKS_PER_SEC << "sec" << endl;
| ^~~~~
|
s723154409
|
p00009
|
C++
|
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include <sstream>
using namespace std;
int main(void){
int n,ans,i;
while(cin >> n){
ans = 0;
if(n < 2){
cout << 0;
continue;
}else if(n == 2){
cout << 1;
}else{
ans++;
}
for(i = 3; i <= n; i += 2){
if(ceil(sqrti) == floor(sqrti)){
continue;
}
ans++;
}
cout << ans << endl;
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:27:21: error: 'sqrti' was not declared in this scope; did you mean 'sqrtl'?
27 | if(ceil(sqrti) == floor(sqrti)){
| ^~~~~
| sqrtl
|
s595735001
|
p00009
|
C++
|
#include <iostream>
using namespace std;
const int MAX_V = 1000000; // 100????????§?´???°??¨?????????
const int prime[MAX_V+1]; // 1????´???°???0????´???°??§??????
const pcount[MAX_V+1];
int main() {
int i, k,a,sum=0;
for(i = 2; i <= MAX_V; i++) {
prime[i] = 1; // 2??\????´???°??¨??????
}
for(i = 2; i*i <= MAX_V; i++) {
if(prime[i]) {
for(k = 2 * i; k <= MAX_V; k += i) {
prime[k] = 0; // ?´???°2?????\????????°?´???°??§??????
}
}
}
pcount[0]=0;
pcount[1]=0;
for(i=2;i<MAX_V;i++){
if(prime[i]){
sum++;
}
pcount[i]=sum;
}
for(i=0;i<30;i++){
scanf("%d",&a);
printf("%d\n",pcount[a]);
}
return 0;
}
|
a.cc:4:11: error: uninitialized 'const prime' [-fpermissive]
4 | const int prime[MAX_V+1]; // 1????´???°???0????´???°??§??????
| ^~~~~
a.cc:5:7: error: 'pcount' does not name a type
5 | const pcount[MAX_V+1];
| ^~~~~~
a.cc: In function 'int main()':
a.cc:9:18: error: assignment of read-only location 'prime[i]'
9 | prime[i] = 1; // 2??\????´???°??¨??????
| ~~~~~~~~~^~~
a.cc:14:26: error: assignment of read-only location 'prime[k]'
14 | prime[k] = 0; // ?´???°2?????\????????°?´???°??§??????
| ~~~~~~~~~^~~
a.cc:20:5: error: 'pcount' was not declared in this scope
20 | pcount[0]=0;
| ^~~~~~
|
s068618887
|
p00009
|
C++
|
include <stdio.h>
const int MAX_V = 1000000;
int prime[MAX_V+1],sum[MAX_V+2]={0};
int main(){
int n;
for(int i = 2;i <= MAX_V;i++){
prime[i] = 1;
}
for(int i = 2;i * i <= MAX_V;i++){
if(prime[i]){
for(int k = 2* i;k <= MAX_V;k += i)
prime[k]=0;
}
}
for(int i = 2;i < MAX_V;i++){
sum[i] +=sum[i-1]+prime[i];
}
while(scanf("%d",&n)!=EOF){
printf("%d\n",sum[n]);
}
return 0;
}
|
a.cc:1:1: error: 'include' does not name a type
1 | include <stdio.h>
| ^~~~~~~
a.cc:3:11: error: 'MAX_V' was not declared in this scope
3 | int prime[MAX_V+1],sum[MAX_V+2]={0};
| ^~~~~
a.cc:3:24: error: 'MAX_V' was not declared in this scope
3 | int prime[MAX_V+1],sum[MAX_V+2]={0};
| ^~~~~
a.cc: In function 'int main()':
a.cc:6:22: error: 'MAX_V' was not declared in this scope
6 | for(int i = 2;i <= MAX_V;i++){
| ^~~~~
a.cc:7:5: error: 'prime' was not declared in this scope
7 | prime[i] = 1;
| ^~~~~
a.cc:9:26: error: 'MAX_V' was not declared in this scope
9 | for(int i = 2;i * i <= MAX_V;i++){
| ^~~~~
a.cc:10:8: error: 'prime' was not declared in this scope
10 | if(prime[i]){
| ^~~~~
a.cc:15:21: error: 'MAX_V' was not declared in this scope
15 | for(int i = 2;i < MAX_V;i++){
| ^~~~~
a.cc:16:5: error: 'sum' was not declared in this scope
16 | sum[i] +=sum[i-1]+prime[i];
| ^~~
a.cc:16:23: error: 'prime' was not declared in this scope
16 | sum[i] +=sum[i-1]+prime[i];
| ^~~~~
a.cc:18:9: error: 'scanf' was not declared in this scope
18 | while(scanf("%d",&n)!=EOF){
| ^~~~~
a.cc:18:25: error: 'EOF' was not declared in this scope
18 | while(scanf("%d",&n)!=EOF){
| ^~~
a.cc:1:1: note: 'EOF' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
+++ |+#include <cstdio>
1 | include <stdio.h>
a.cc:19:19: error: 'sum' was not declared in this scope
19 | printf("%d\n",sum[n]);
| ^~~
a.cc:19:5: error: 'printf' was not declared in this scope
19 | printf("%d\n",sum[n]);
| ^~~~~~
a.cc:19:5: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
|
s735368823
|
p00009
|
C++
|
#include <stdio.h>
#include <iostream>
const int MAX_V = 10000;
int prime[MAX_V+1];
void init(){
int i, k, v;
for(i=2; i<=MAX_V; i++){
prime[i] = 1;
}
for(i=2; i*i<=MAX_V; i++){
if(prime[i]){
for(k=2*i; k<=MAX_V; k+=i){
prime[k]=0;
}
}
}
}
int isprime(int n){
return prime[n];
}
int main(){
init();
int num;
// while(1){
while(cin >> num){
int count=0;
// scanf("%d", &num);
for(int i=2; i<=num; i++){
if(isprime(i)==1)
count++;
}
printf("%d\n", count);
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:29:11: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
29 | while(cin >> num){
| ^~~
| std::cin
In file included from a.cc:2:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
62 | extern istream cin; ///< Linked to standard input
| ^~~
|
s364960798
|
p00009
|
C++
|
import math
while True:
try:
n = int(input())
c = [1 for i in range(n)]
c[0] = 0
i = 2
while i**2 <= n:
j = i*2
while j <= n:
c[j - 1] = 0
j += i
i += 1
print(sum(c))
except:
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'
|
s622847973
|
p00009
|
C++
|
#include<iostream>
using namespace std;
int get_num_of_under_n(int n) {
bool* numbers = new bool[n + 1];
for (int i = 2; i < n + 1; i++) {
numbers[i] = true;
}
for (int i = 2; i < sqrt(n); i++) {
if (numbers[i] == true) {
for (int j = 0; i*(j + 2) <= n; j++) {
numbers[i*(j + 2)] = false;
}
}
}
int ans = 0;
for (int i = 2; i < n + 1; i++) {
if (numbers[i] == true)ans++;
}
return ans;
}
int main() {
int n;
while (cin>>n) {
cout << get_num_of_under_n(n)<<endl;
}
}
|
a.cc: In function 'int get_num_of_under_n(int)':
a.cc:9:29: error: 'sqrt' was not declared in this scope
9 | for (int i = 2; i < sqrt(n); i++) {
| ^~~~
|
s933341768
|
p00009
|
C++
|
#include <iostream>
#include <cstdio>
using namespace std;
bool isPrime(int x) {
if (x==2) {
return true;
}
if (x<2 || x%2==0) {
return false;
}
i=3;
while (i*i<=x) {
if (x%i==0) {
return false;
}
i+=2;
}
/*for (int i=3; i*i<=x; i+=2) {
if (x%i==0) {
return false;
}
}*/
return true;
}
int main() {
int n;
int cnt;
while (cin >> n) {
cnt=0;
for (int i=0; i<=n; i++) {
if (isPrime(i)) {
cnt++;
}
}
printf("%d\n",cnt);
}
return 0;
}
|
a.cc: In function 'bool isPrime(int)':
a.cc:12:5: error: 'i' was not declared in this scope
12 | i=3;
| ^
|
s663278589
|
p00009
|
C++
|
include <iostream>
using namespace std;
int main(){
bool is_prime[1000000];
is_prime[0]=is_prime[1]=false;
for(int i=2;i<1000000;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_prime[j]=false;
}
}
}
int n[1000000];
int count=0;
for(int i=0;i<1000000;i++){
if(is_prime[i])
count++;
n[i]=count;
}
while(true){
int x;
cin >> x;
if(cin.eof())
break;
cout << n[x] << endl;
}
return 0;
}
|
a.cc:1:1: error: 'include' does not name a type
1 | include <iostream>
| ^~~~~~~
a.cc: In function 'int main()':
a.cc:25:7: error: 'cin' was not declared in this scope
25 | cin >> x;
| ^~~
a.cc:28:7: error: 'cout' was not declared in this scope; did you mean 'count'?
28 | cout << n[x] << endl;
| ^~~~
| count
a.cc:28:23: error: 'endl' was not declared in this scope
28 | cout << n[x] << endl;
| ^~~~
|
s252985279
|
p00009
|
C++
|
#include<iostream>
using namespace std;
int sushu(int a)
{
int flag = 1;
for (int i = 2; i < sqrt(a)+1; i++)
{
if (a%i == 0)
{
flag = 0;
break;
}
}
return flag;
}
int main()
{
int n;
while (cin >> n)
{
int ans = 0, flag = 1;
if (n == 1)
cout << ans << endl;
else
{
for (int i = 2; i <= n; i++)
{
flag = sushu(i);
if (flag)
ans++;
}
cout << ans+1 << endl;
}
}
return 0;
}
|
a.cc: In function 'int sushu(int)':
a.cc:6:29: error: 'sqrt' was not declared in this scope
6 | for (int i = 2; i < sqrt(a)+1; i++)
| ^~~~
|
s354400105
|
p00009
|
C++
|
#include <iostream>
//#include <vector>
//#include <math.h>
//#include <string>
//#include <cmath>
int main(void);
int count_prime_number(int n);
int main(){
int n;
int cnt = 0;
int result[30];
//while (cnt < 3){
//std::cin >> n;
while (std::cin >> n){
result[cnt] = count_prime_number(n);
cnt++;
}
for (int i = 0; i < cnt; i++){
std::cout << result[i] << std::endl;
}
//while (1);
return 0;
}
//0..nまでの素数の個数を出力する
//args:数値
//return:素数の個数
int count_prime_number(int n){
int rtn = 0;
//2だけ個別チェック
if (n >= 2){
rtn++;
}
for (int i = 3; i <= n; i+= 2)
{
bool is_prime_num = true;
for (int j = 3; j <= sqrt(i); j+= 2) //ルートi以上のiの約数はルートi以下のiの約数と対になっているので範囲はルートiまででいい
{
if (i % j == 0)
{
is_prime_num = false;
break;
}
}
if (is_prime_num){
rtn++;
//デバッグ
//std::cout << i << std::endl;
}
}
return rtn;
}
|
a.cc: In function 'int count_prime_number(int)':
a.cc:45:38: error: 'sqrt' was not declared in this scope
45 | for (int j = 3; j <= sqrt(i); j+= 2) //ルートi以上のiの約数はルートi以下のiの約数と対になっているので範囲はルートiまででいい
| ^~~~
|
s805042868
|
p00009
|
C++
|
#include <iostream>
//#include <vector>
//#include <math.h>
//#include <string>
//#include <cmath>
int main(void);
int count_prime_number(int n);
int main(){
int n;
int cnt = 0;
int result[30];
//while (cnt < 3){
//std::cin >> n;
while (std::cin >> n){
result[cnt] = count_prime_number(n);
cnt++;
}
for (int i = 0; i < cnt; i++){
std::cout << result[i] << std::endl;
}
//while (1);
return 0;
}
//0..nまでの素数の個数を出力する
//args:数値
//return:素数の個数
int count_prime_number(int n){
int rtn = 0;
//2だけ個別チェック
if (n >= 2){
rtn++;
}
for (int i = 3; i <= n; i+= 2)
{
bool is_prime_num = true;
for (int j = 3; j <= sqrt(i); j+= 2) //ルートi以上のiの約数はルートi以下のiの約数と対になっているので範囲はルートiまででいい
{
if (i % j == 0)
{
is_prime_num = false;
break;
}
}
if (is_prime_num){
rtn++;
//デバッグ
//std::cout << i << std::endl;
}
}
return rtn;
}
|
a.cc: In function 'int count_prime_number(int)':
a.cc:45:38: error: 'sqrt' was not declared in this scope
45 | for (int j = 3; j <= sqrt(i); j+= 2) //ルートi以上のiの約数はルートi以下のiの約数と対になっているので範囲はルートiまででいい
| ^~~~
|
s397023053
|
p00009
|
C++
|
#include <iostream>
//#include <vector>
//#include <math.h>
//#include <string>
//#include <cmath>
int main(void);
int count_prime_number(int n);
int main(){
int n;
int cnt = 0;
int result[30];
//while (cnt < 3){
//std::cin >> n;
while (std::cin >> n){
result[cnt] = count_prime_number(n);
cnt++;
}
for (int i = 0; i < cnt; i++){
std::cout << result[i] << std::endl;
}
//while (1);
return 0;
}
//0..nまでの素数の個数を出力する
//args:数値
//return:素数の個数
int count_prime_number(int n){
int rtn = 0;
//2だけ個別チェック
if (n >= 2){
rtn++;
}
for (int i = 3; i <= n; i+= 2)
{
bool is_prime_num = true;
for (int j = 3; j <= sqrt(i); j+= 2) //ルートi以上のiの約数はルートi以下のiの約数と対になっているので範囲はルートiまででいい
{
if (i % j == 0)
{
is_prime_num = false;
break;
}
}
if (is_prime_num){
rtn++;
//デバッグ
//std::cout << i << std::endl;
}
}
return rtn;
}
|
a.cc: In function 'int count_prime_number(int)':
a.cc:45:38: error: 'sqrt' was not declared in this scope
45 | for (int j = 3; j <= sqrt(i); j+= 2) //ルートi以上のiの約数はルートi以下のiの約数と対になっているので範囲はルートiまででいい
| ^~~~
|
s099695931
|
p00009
|
C++
|
#include <iostream>
//#include <vector>
//#include <math.h>
//#include <string>
//#include <cmath>
int main(void);
int count_prime_number(int n);
int main(){
int n;
int cnt = 0;
int result[30];
//while (cnt < 3){
//std::cin >> n;
while (std::cin >> n){
result[cnt] = count_prime_number(n);
cnt++;
}
for (int i = 0; i < cnt; i++){
std::cout << result[i] << std::endl;
}
//while (1);
return 0;
}
//0..nまでの素数の個数を出力する
//args:数値
//return:素数の個数
int count_prime_number(int n){
int rtn = 0;
//2だけ個別チェック
if (n >= 2){
rtn++;
}
for (int i = 3; i <= n; i+= 2)
{
bool is_prime_num = true;
for (int j = 3; j <= sqrt(i); j+= 2) //ルートi以上のiの約数はルートi以下のiの約数と対になっているので範囲はルートiまででいい
{
if (i % j == 0)
{
is_prime_num = false;
break;
}
}
if (is_prime_num){
rtn++;
//デバッグ
//std::cout << i << std::endl;
}
}
return rtn;
}
|
a.cc: In function 'int count_prime_number(int)':
a.cc:45:38: error: 'sqrt' was not declared in this scope
45 | for (int j = 3; j <= sqrt(i); j+= 2) //ルートi以上のiの約数はルートi以下のiの約数と対になっているので範囲はルートiまででいい
| ^~~~
|
s818318404
|
p00009
|
C++
|
#include <cassert>
#include <iostream>
using namespace std;
constexpr int ceil_sqrt(int x) {
int ans = 0;
while (ans*ans < x) { ++ans; }
return ans;
}
template<int size>
struct Sieve {
constexpr Sieve(): factor(), primes() {
factor[0] = factor[1] = 1;
for (int p = 2; p < size; ++p) {
primes[p] = primes[p-1] + (factor[p]?0:1);
if (factor[p]) { continue; }
for (int n = 2*p; n < size; n += p) {
factor[n] = p;
}
}
}
constexpr bool is_prime(int n) const {
assert(n < size);
return !(factor[n]);
}
int factor[size];
int primes[size];
};
constexpr int NMAX = 1200000;
constexpr auto sieve = Sieve<NMAX>();
int main() {
int N = 0;
while (cin >> N) {
cout << sieve.primes[N] << endl;
}
return 0;
}
|
a.cc:33:36: in 'constexpr' expansion of 'Sieve<1200000>()'
a.cc:19:7: error: 'constexpr' loop iteration count exceeds limit of 262144 (use '-fconstexpr-loop-limit=' to increase the limit)
19 | for (int n = 2*p; n < size; n += p) {
| ^~~
|
s945366123
|
p00009
|
C++
|
#include<iostream>
#include<cstdio>
using namespace std;
const int len 200000
int prime[len];
int a;
bool mark[len];
void f()
{
a=0;
long long int i,j;
for( i=0; i<len; i++)
{
mark[i]=false;
}
for( i=2; i<len; i++)
{
if(mark[i]==1)
continue;
else
{
prime[a++]=i;
for( j=i*i; j<len; j+=i)
{
mark[j]=true;
}
}
}
}
int main()
{
f();
int n;
while(scanf("%d",&n)!=EOF)
{
printf("%d\n",prime[n-1]);
}
return 0;
}
|
a.cc:4:15: error: expected initializer before numeric constant
4 | const int len 200000
| ^~~~~~
a.cc:7:11: error: 'len' was not declared in this scope; did you mean 'mblen'?
7 | bool mark[len];
| ^~~
| mblen
a.cc: In function 'void f()':
a.cc:13:17: error: 'len' was not declared in this scope; did you mean 'mblen'?
13 | for( i=0; i<len; i++)
| ^~~
| mblen
a.cc:15:9: error: 'mark' was not declared in this scope
15 | mark[i]=false;
| ^~~~
a.cc:17:17: error: 'len' was not declared in this scope; did you mean 'mblen'?
17 | for( i=2; i<len; i++)
| ^~~
| mblen
a.cc:19:12: error: 'mark' was not declared in this scope
19 | if(mark[i]==1)
| ^~~~
a.cc:23:13: error: 'prime' was not declared in this scope
23 | prime[a++]=i;
| ^~~~~
a.cc: In function 'int main()':
a.cc:39:23: error: 'prime' was not declared in this scope
39 | printf("%d\n",prime[n-1]);
| ^~~~~
|
s384206841
|
p00009
|
C++
|
#include<iostream>
#include<vector>
#define MAX 1000000
using namespace std;
int main(){
vector<int> v(MAX);
for(int i = 0;i<MAX;i++)
v[i]=true;
v[0]=false;
v[1]=false;
for(int i = 2;i<MAX;i++){
if(v[i]==true){
for(long long int = (long long int)i*i;j<MAX;j=j*j){
v[j]=false;
}
}
}
for(int i = 2;i<MAX;i++)v[i]+=v[i-1];
while(true){
int a;
cin >> a;
if(cin.eof())return 0;
cout << v[a]<<endl;
}
}
|
a.cc: In function 'int main()':
a.cc:14:28: error: expected unqualified-id before '=' token
14 | for(long long int = (long long int)i*i;j<MAX;j=j*j){
| ^
a.cc:14:26: error: expected ';' before '=' token
14 | for(long long int = (long long int)i*i;j<MAX;j=j*j){
| ^ ~
| ;
a.cc:14:28: error: expected primary-expression before '=' token
14 | for(long long int = (long long int)i*i;j<MAX;j=j*j){
| ^
a.cc:14:49: error: 'j' was not declared in this scope
14 | for(long long int = (long long int)i*i;j<MAX;j=j*j){
| ^
a.cc:14:54: error: expected ')' before ';' token
14 | for(long long int = (long long int)i*i;j<MAX;j=j*j){
| ~ ^
a.cc:14:55: error: 'j' was not declared in this scope
14 | for(long long int = (long long int)i*i;j<MAX;j=j*j){
| ^
|
s001740952
|
p00009
|
C++
|
#include<iostream>
#include<vector>
#define MAX 1000000
using namespace std;
int main(){
vector<int> v(MAX);
for(int i = 0;i<MAX;i++)
v[i]=true;
v[0]=false;
v[1]=false;
for(int i = 2;i<MAX;i++){
if(v[i]==true){
for(long long int = (long long int)i*i;j<MAX;j=j*j){
v[j]=false;
}
}
}
for(int i = 2;i<MAX;i++)v[i]+=v[i-1];
while(true){
int a;
cin >> a;
if(cin.eof())return 0;
cout << v[a]<<endl;
}
}
|
a.cc: In function 'int main()':
a.cc:14:28: error: expected unqualified-id before '=' token
14 | for(long long int = (long long int)i*i;j<MAX;j=j*j){
| ^
a.cc:14:26: error: expected ';' before '=' token
14 | for(long long int = (long long int)i*i;j<MAX;j=j*j){
| ^ ~
| ;
a.cc:14:28: error: expected primary-expression before '=' token
14 | for(long long int = (long long int)i*i;j<MAX;j=j*j){
| ^
a.cc:14:49: error: 'j' was not declared in this scope
14 | for(long long int = (long long int)i*i;j<MAX;j=j*j){
| ^
a.cc:14:54: error: expected ')' before ';' token
14 | for(long long int = (long long int)i*i;j<MAX;j=j*j){
| ~ ^
a.cc:14:55: error: 'j' was not declared in this scope
14 | for(long long int = (long long int)i*i;j<MAX;j=j*j){
| ^
|
s917772985
|
p00009
|
C++
|
#include <iostream>
using namespace std;
int main(){
bool is_prime[1000000];
is_prime[0]=is_prime[1]=false;
for(int i=2;i<1000000i++){
is_prime[i] = true;
}
for(int i=2;i*i<1000000;i++){
if(is_prime[i]){
for(int j=i*i;j<1000000;j=j+i){
is_prime[j] = 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:8:25: error: lvalue required as increment operand
8 | for(int i=2;i<1000000i++){
| ^~
a.cc:8:27: error: expected ';' before ')' token
8 | for(int i=2;i<1000000i++){
| ^
| ;
|
s656125994
|
p00009
|
C++
|
#include <iostream>
using namespace std;
bool IsPrime(int n) {
for(int i = 2; i*i <= n; i++) {
if(n % i == 0) {
return false;
}
}
return true;
}
int main(void){
int count = 0;
int n;
cin >> n;
for(int i=0; i<n; i++){
int p;
cin >> p;
if(IsPrime(p)){
count++;
}
}
count << count << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:24:24: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'
24 | count << count << endl;
| ~~~~~~~~~~~~~~~^~~~~~~
|
s747807783
|
p00009
|
C++
|
#include <iostream>
using namespace std;
bool IsPrime(int x) {
return true; /* ダミー: 全て素数と判定 */
}
int main(void){
int count = 0, n;
cin >> n; /* n個整数を読む */
for(int i = 0; i < n; i++) {
int p;
cin >> p;
if(IsPrime(p)) {
bool IsPrime(int n) {
for(int i = 2; i*i <= n; i++) {
if(n % i == 0) {
return false;
}
}
return true;
}
}
}
cout << count << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:15:30: error: a function-definition is not allowed here before '{' token
15 | bool IsPrime(int n) {
| ^
|
s168093470
|
p00009
|
C++
|
#include <iostream>
bool IsPrime(int n) {
for(int i = 2; i*i <= n; i++) {
if(n % i == 0) {
return false;
}
}
return true;
}
int main() {
// your code goes here
int n;
while(1){
cin >> n;
if(cin.eof()){
break;
}
int count = 0;
for(int i=2;i<=n;i++){
if(IsPrime(i)){
count++;
}
}
cout << count << endl;
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:17:17: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
17 | 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 << count << 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:34: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
27 | cout << count << 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)
| ^~~~
|
s949039838
|
p00009
|
C++
|
#include <iostream>
using namespace std;
int main(){
bool is_prime[1000000];
is_prime[0]=is_prime[1]=false;
for(int i=2;i<1000000i++){
is_prime[i] = true;
}
for(int i=2;i*i<1000000;i++){
if(is_prime[i]){
for(int j=i*i;j<1000000;j=j+i){
is_prime[j] = 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:8:25: error: lvalue required as increment operand
8 | for(int i=2;i<1000000i++){
| ^~
a.cc:8:27: error: expected ';' before ')' token
8 | for(int i=2;i<1000000i++){
| ^
| ;
|
s233224160
|
p00009
|
C++
|
#include <iostream>
using namespace std;
bool IsPrime(int n){
for(int i=2;i*i<=n;i++){
if(n%i == 0){return false;}
}
return true;
}
int main(void) {
int n;
while(cin >> n){
for(i=2;i<=n;i++){
if(IsPrime(i)) count++;
}
cout << count << endl;
}
return 0;
}
|
a.cc:17:2: error: extended character is not valid in an identifier
17 | if(IsPrime(i)) count++;
| ^
a.cc:17:2: error: extended character is not valid in an identifier
a.cc:18:2: error: extended character is not valid in an identifier
18 | }
| ^
a.cc: In function 'int main()':
a.cc:16:13: error: 'i' was not declared in this scope
16 | for(i=2;i<=n;i++){
| ^
a.cc:17:2: error: '\U00003000\U00003000' was not declared in this scope
17 | if(IsPrime(i)) count++;
| ^~~~
a.cc:18:2: error: '\U00003000' was not declared in this scope
18 | }
| ^~
a.cc:19:17: error: 'count' was not declared in this scope
19 | cout << count << endl;
| ^~~~~
|
s850138282
|
p00009
|
C++
|
#include <iostream>
using namespace std;
int main(){
int n,k,kk;
while(cin>>n){
kk=0;
for(int j=3;j<=n;j+=2){
k=0;
for(int i=3;i<=sqrt(j);i+=2){
if(j%i==0)k++;
}
if(k==1)kk++;
}
if(n==1)cout<<"0"<<endl;
else if(n==2)cout<<"1"<<endl;
else cout<<kk+1<<endl;
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:9:40: error: 'sqrt' was not declared in this scope
9 | for(int i=3;i<=sqrt(j);i+=2){
| ^~~~
|
s961112039
|
p00009
|
C++
|
std::vector<bool> IsPrime;
void sieve(size_t max){
if(max+1 > IsPrime.size()){
IsPrime.resize(max+1,true);
}
IsPrime[0] = false;
IsPrime[1] = false;
for(size_t i=2; i*i<=max; ++i)
if(IsPrime[i])
for(size_t j=2; i*j<=max; ++j)
IsPrime[i*j] = false;
}
|
a.cc:1:6: error: 'vector' in namespace 'std' does not name a template type
1 | std::vector<bool> IsPrime;
| ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
+++ |+#include <vector>
1 | std::vector<bool> IsPrime;
a.cc:3:6: error: variable or field 'sieve' declared void
3 | void sieve(size_t max){
| ^~~~~
a.cc:3:12: error: 'size_t' was not declared in this scope
3 | void sieve(size_t max){
| ^~~~~~
a.cc:1:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
+++ |+#include <cstddef>
1 | std::vector<bool> IsPrime;
|
s095977276
|
p00009
|
C++
|
#include<stdio.h> int main(void){ int a,b,r,ans,a1,b1; double c; while(scanf("%d %d",&a,&b)!=EOF){ a1=a,b1=b; while(1){ r=a%b; if(r==0){ ans=b; break; }else{ a=b; b=r; } } c=(double)(a1)*(double)(b1)/(double)(ans); printf("%d %.0f\n",ans,c); } return 0; }
|
a.cc:1:19: warning: extra tokens at end of #include directive
1 | #include<stdio.h> int main(void){ int a,b,r,ans,a1,b1; double c; while(scanf("%d %d",&a,&b)!=EOF){ a1=a,b1=b; while(1){ r=a%b; if(r==0){ ans=b; break; }else{ a=b; b=r; } } c=(double)(a1)*(double)(b1)/(double)(ans); printf("%d %.0f\n",ans,c); } return 0; }
| ^~~
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
|
s629824660
|
p00009
|
C++
|
#include<stdio.h> int prime[1000000]; int main(){ prime[0]=-1; prime[1]=-1; for(int i=2;i<1000000;i++){ if(prime[i]==0){ prime[i]=1; for(int j=i*2;j<1000000;j+=i)prime[j]=-1; } } int now; while(~scanf("%d",&now)){ int ans=0; for(int i=1;i<now+1;i++)if(prime[i]==1)ans++; printf("%d\n",ans); } }
|
a.cc:1:19: warning: extra tokens at end of #include directive
1 | #include<stdio.h> int prime[1000000]; int main(){ prime[0]=-1; prime[1]=-1; for(int i=2;i<1000000;i++){ if(prime[i]==0){ prime[i]=1; for(int j=i*2;j<1000000;j+=i)prime[j]=-1; } } int now; while(~scanf("%d",&now)){ int ans=0; for(int i=1;i<now+1;i++)if(prime[i]==1)ans++; printf("%d\n",ans); } }
| ^~~
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
|
s509458614
|
p00009
|
C++
|
#define _USE_MATH_DEFINES
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
int N;
while(cin >> N)
double p = std::log2(N);
while (cin >> N){
int sum =0;
cout << N*p << endl;
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:14:27: error: 'p' was not declared in this scope
14 | cout << N*p << endl;
| ^
|
s610734675
|
p00009
|
C++
|
#define _USE_MATH_DEFINES
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
int N;
while(cin >> N)
double p = log2(N);
while (cin >> N){
int sum =0;
cout << N*p << endl;
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:14:27: error: 'p' was not declared in this scope
14 | cout << N*p << endl;
| ^
|
s031840434
|
p00009
|
C++
|
import sys
def prime_calc(n):
if n < 2:
return False
else:
i = 2
while n > i:
if n % i == 0:
return False
else:
i += 1
return True
def prime(n):
cnt = 0
for i in range(0, n+1):
ans = prime_calc(i)
if ans is True:
cnt = cnt + 1
return cnt
def main():
a = []
for line in sys.stdin:
a.append(int(line))
for line in l:
print(prime(line))
if __name__ == "__main__":
main()
|
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'
|
s095103477
|
p00009
|
C++
|
#include<iostream>
#define MAX 1000000
using namespace std;
bool prime[MAX+1];
int T[MAX];
void eratos( int n ){
for ( int i = 0; i < n; i++ ) prime[i] = false;
for ( int i = 3; i <= n; i += 2 ) prime[i] = true;
prime[2] = true;
for ( int i = 3, limit = (int)sqrt(n); i <= limit; i += 2 ) {
if ( !prime[i] ) continue;
for ( int j = i * i, k = i * 2; j <= n; j += k ) prime[j] = false;
}
}
void initialize(){
eratos( MAX );
for ( int i = 0; i < MAX; i++ ){
T[i] = T[i - 1];
if ( prime[i] ) T[i]++;
}
}
main(){
initialize();
int n;
while ( cin >> n ) cout << T[n] << endl;
}
|
a.cc: In function 'void eratos(int)':
a.cc:13:35: error: 'sqrt' was not declared in this scope
13 | for ( int i = 3, limit = (int)sqrt(n); i <= limit; i += 2 ) {
| ^~~~
a.cc: At global scope:
a.cc:27:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
27 | main(){
| ^~~~
|
s181175864
|
p00009
|
C++
|
import java.util.*;
import java.io.*;
class Main
{
public static void main(String[] args)
{
Boorean[] bit = new Boorean[1000000];
Arrays.fill(bit, true);
bit[0] = false;
bit[1] = false;
for(int i=2; i<1000; ++i){
if(bit[i]){
for(int j=i*2; j<1000000; j+=i)
bit[j] = false;
}
}
int[] prime = new int[1000000];
prime[0] = 0;
for(int i=1; i<1000000; ++i)
prime[i] = prime[i-1] + (bit[i] ? 1 : 0);
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
String str;
try{
while((str = bf.readLine()) != null){
int n = Integer.parseInt(str);
System.out.println(prime[n]);
}
}
catch(IOException ex){
System.out.println(ex);
}
}
}
|
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: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:6:15: error: expected ':' before 'static'
6 | public static void main(String[] args)
| ^~~~~~~
| :
a.cc:6:33: error: 'String' has not been declared
6 | public static void main(String[] args)
| ^~~~~~
a.cc:6:42: error: expected ',' or '...' before 'args'
6 | public static void main(String[] args)
| ^~~~
a.cc:37:2: error: expected ';' after class definition
37 | }
| ^
| ;
a.cc: In static member function 'static void Main::main(int*)':
a.cc:8:17: error: 'Boorean' was not declared in this scope
8 | Boorean[] bit = new Boorean[1000000];
| ^~~~~~~
a.cc:8:25: error: expected primary-expression before ']' token
8 | Boorean[] bit = new Boorean[1000000];
| ^
a.cc:9:17: error: 'Arrays' was not declared in this scope
9 | Arrays.fill(bit, true);
| ^~~~~~
a.cc:9:29: error: 'bit' was not declared in this scope
9 | Arrays.fill(bit, true);
| ^~~
a.cc:20:20: error: structured binding declaration cannot have type 'int'
20 | int[] prime = new int[1000000];
| ^~
a.cc:20:20: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:20:20: error: empty structured binding declaration
a.cc:20:23: error: expected initializer before 'prime'
20 | int[] prime = new int[1000000];
| ^~~~~
a.cc:21:17: error: 'prime' was not declared in this scope
21 | prime[0] = 0;
| ^~~~~
a.cc:25:17: error: 'BufferedReader' was not declared in this scope
25 | BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
| ^~~~~~~~~~~~~~
a.cc:26:17: error: 'String' was not declared in this scope
26 | String str;
| ^~~~~~
a.cc:28:32: error: 'str' was not declared in this scope; did you mean 'std'?
28 | while((str = bf.readLine()) != null){
| ^~~
| std
a.cc:28:38: error: 'bf' was not declared in this scope
28 | while((str = bf.readLine()) != null){
| ^~
a.cc:28:56: error: 'null' was not declared in this scope
28 | while((str = bf.readLine()) != null){
| ^~~~
a.cc:29:41: error: 'Integer' was not declared in this scope
29 | int n = Integer.parseInt(str);
| ^~~~~~~
a.cc:30:33: error: 'System' was not declared in this scope
30 | System.out.println(prime[n]);
| ^~~~~~
a.cc:33:23: error: 'IOException' does not name a type
33 | catch(IOException ex){
| ^~~~~~~~~~~
a.cc:34:25: error: 'System' was not declared in this scope
34 | System.out.println(ex);
| ^~~~~~
a.cc:34:44: error: 'ex' was not declared in this scope
34 | System.out.println(ex);
| ^~
|
s132631512
|
p00009
|
C++
|
#include <stdio.h>
main(n){
int b[100000],i,j;
while(~scanf("%d",&n)){
n++;
for(i=2;i<n;i++)b[i]=1;
for(i=2;i<n;i++)for(j=i*2;j<n;j+=i)b[j]=0;
for(i=2,j=0;i<n;i++)j+=b[i]?1:0;
printf("%d\n",j);
}
}
|
a.cc:2:5: error: expected constructor, destructor, or type conversion before '(' token
2 | main(n){
| ^
|
s235999488
|
p00009
|
C++
|
#include <iostream>
#include <bitset>
using namespace std;
int main() {
bitset<1000000> primes;
int i, j, n, ans;
for (n = 0; n <= 999999; n++) {
primes.reset();
for (i = 2; i <= n; i++)
if (primes[i] == false)
for (j = i + i; j <= n; j += i)
primes[j] = true;
cout << n == 0 ? 0: n - primes.count() - 1 << endl;
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:15:15: error: no match for 'operator==' (operand types are 'std::basic_ostream<char>' and 'int')
15 | cout << n == 0 ? 0: n - primes.count() - 1 << endl;
| ~~~~~~~~~ ^~ ~
| | |
| | int
| std::basic_ostream<char>
a.cc:15:15: note: candidate: 'operator==(int, int)' (built-in)
15 | cout << n == 0 ? 0: n - primes.count() - 1 << endl;
| ~~~~~~~~~~^~~~
a.cc:15:15: note: no known conversion for argument 1 from 'std::basic_ostream<char>' to 'int'
In file included from /usr/include/c++/14/iosfwd:42,
from /usr/include/c++/14/ios:40,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)'
192 | operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/postypes.h:192:5: note: template argument deduction/substitution failed:
a.cc:15:18: note: 'std::basic_ostream<char>' is not derived from 'const std::fpos<_StateT>'
15 | cout << n == 0 ? 0: n - primes.count() - 1 << endl;
| ^
In file included from /usr/include/c++/14/string:43,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44:
/usr/include/c++/14/bits/allocator.h:235:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const allocator<_CharT>&, const allocator<_T2>&)'
235 | operator==(const allocator<_T1>&, const allocator<_T2>&)
| ^~~~~~~~
/usr/include/c++/14/bits/allocator.h:235:5: note: template argument deduction/substitution failed:
a.cc:15:18: note: 'std::basic_ostream<char>' is not derived from 'const std::allocator<_CharT>'
15 | cout << n == 0 ? 0: n - primes.count() - 1 << endl;
| ^
In file included from /usr/include/c++/14/string:48:
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
441 | operator==(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: template argument deduction/substitution failed:
a.cc:15:18: note: 'std::basic_ostream<char>' is not derived from 'const std::reverse_iterator<_Iterator>'
15 | cout << n == 0 ? 0: n - primes.count() - 1 << endl;
| ^
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
486 | operator==(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: template argument deduction/substitution failed:
a.cc:15:18: note: 'std::basic_ostream<char>' is not derived from 'const std::reverse_iterator<_Iterator>'
15 | cout << n == 0 ? 0: n - primes.count() - 1 << endl;
| ^
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1667 | operator==(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: template argument deduction/substitution failed:
a.cc:15:18: note: 'std::basic_ostream<char>' is not derived from 'const std::move_iterator<_IteratorL>'
15 | cout << n == 0 ? 0: n - primes.count() - 1 << endl;
| ^
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1737 | operator==(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: template argument deduction/substitution failed:
a.cc:15:18: note: 'std::basic_ostream<char>' is not derived from 'const std::move_iterator<_IteratorL>'
15 | cout << n == 0 ? 0: n - primes.count() - 1 << endl;
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/string:51:
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1033 | operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: template argument deduction/substitution failed:
a.cc:15:18: note: 'std::basic_ostream<char>' is not derived from 'const std::pair<_T1, _T2>'
15 | cout << n == 0 ? 0: n - primes.count() - 1 << endl;
| ^
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54:
/usr/include/c++/14/string_view:629:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
629 | operator==(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:629:5: note: template argument deduction/substitution failed:
a.cc:15:18: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
15 | cout << n == 0 ? 0: n - primes.count() - 1 << endl;
| ^
/usr/include/c++/14/string_view:637:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
637 | operator==(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:637:5: note: template argument deduction/substitution failed:
a.cc:15:18: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
15 | cout << n == 0 ? 0: n - primes.count() - 1 << endl;
| ^
/usr/include/c++/14/string_view:644:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
644 | operator==(__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:644:5: note: template argument deduction/substitution failed:
a.cc:15:18: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int'
15 | cout << n == 0 ? 0: n - primes.count() - 1 << endl;
| ^
/usr/include/c++/14/bits/basic_string.h:3755:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3755 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3755:5: note: template argument deduction/substitution failed:
a.cc:15:18: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
15 | cout << n == 0 ? 0: n - primes.count() - 1 << endl;
| ^
/usr/include/c++/14/bits/basic_string.h:3772:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
3772 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3772:5: note: template argument deduction/substitution failed:
a.cc:15:18: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
15 | cout << n == 0 ? 0: n - primes.count() - 1 << endl;
| ^
/usr/include/c++/14/bits/basic_string.h:3819:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3819 | operator==(const _CharT* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3819:5: note: template argument deduction/substitution failed:
a.cc:15:18: note: mismatched types 'const _CharT*' and 'std::basic_ostream<char>'
15 | cout << n == 0 ? 0: n - primes.count() - 1 << endl;
| ^
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2558:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator==(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)'
2558 | operator==(const tuple<_TElements...>& __t,
| ^~~~~~~~
/usr/include/c++/14/tuple:2558:5: note: template argument deduction/substitution failed:
a.cc:15:18: note: 'std::basic_ostream<char>' is not derived from 'const std::tuple<_UTypes ...>'
15 | cout << n == 0 ? 0: n - primes.count() - 1 << endl;
| ^
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
from /usr/include/c++/14/bits/basic_ios.h:37,
from /usr/include/c++/14/ios:46:
/usr/include/c++/14/bits/streambuf_iterator.h:234:5: note: candidate: 'template<class _CharT, class _Traits> bool std::operator==(const istreambuf_iterator<_CharT, _Traits>&, const istreambuf_iterator<_CharT, _Traits>&)'
234 | operator==(const istreambuf_iterator<_CharT, _Traits>& __a,
| ^~~~~~~~
/usr/include/c++/14/bits/streambuf_iterator.h:234:5: note: template argument deduction/su
|
s159987959
|
p00009
|
C++
|
#include <iostream>
using namespace std;
int main(){
const int NUM = 1000000;
bool prime[NUM];
prime[0] = false;prime[1] = false;
for(int i=2;i<NUM;i++)
prime[i] = true;
for(int i=2;i*i<NUM;i++)
for(int k=2;i*k<NUM;k++)
prime[i*k]=false;
int n,c=0,i=0;
for(cin>>n;i<n;i++)if(prime[i})count++;
cout<<c<<endl;
return 0;}
|
a.cc: In function 'int main()':
a.cc:13:32: error: expected ']' before '}' token
13 | for(cin>>n;i<n;i++)if(prime[i})count++;
| ^
| ]
a.cc:13:32: error: expected ')' before '}' token
13 | for(cin>>n;i<n;i++)if(prime[i})count++;
| ~ ^
| )
a.cc:13:32: error: expected primary-expression before '}' token
a.cc: At global scope:
a.cc:13:33: error: expected unqualified-id before ')' token
13 | for(cin>>n;i<n;i++)if(prime[i})count++;
| ^
a.cc:14:3: error: 'cout' does not name a type
14 | cout<<c<<endl;
| ^~~~
a.cc:15:3: error: expected unqualified-id before 'return'
15 | return 0;}
| ^~~~~~
a.cc:15:12: error: expected declaration before '}' token
15 | return 0;}
| ^
|
s877246011
|
p00009
|
C++
|
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
public class Main{
Scanner sc;
static final int INF=1<<28;
static final double EPS=1e-9;
void run(){
sc=new Scanner(System.in);
for(;;){
if(!sc.hasNext())
break;
int n=sc.nextInt();
int a=0;
for(int i=2; i<=n; i++)
if(isPrime(i))
a++;
println(""+a);
}
sc.close();
}
boolean isPrime(int n){
int m=(int)sqrt(n);
if(n==2)
return true;
if(n%2==0)
return false;
for(int i=3; i<=m; i++)
if(n%i==0)
return false;
return true;
}
void print(String s){
System.out.print(s);
}
void println(String s){
System.out.println(s);
}
public static void main(String[] args){
new Main().run();
}
}
|
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:2:1: error: 'import' does not name a type
2 | import java.lang.*;
| ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
3 | import java.math.*;
| ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
4 | import java.io.*;
| ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: 'import' does not name a type
6 | import static java.lang.Math.*;
| ^~~~~~
a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:1: error: 'import' does not name a type
7 | import static java.util.Arrays.*;
| ^~~~~~
a.cc:7:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:9:1: error: expected unqualified-id before 'public'
9 | public class Main{
| ^~~~~~
|
s018773597
|
p00009
|
C++
|
#include<iostream>
#include<string>
int main(){for(int m,n,o,c,d,e,i;!(std::cin>>n).eof();){if(n<3)e=n>1;else{bool*v=new bool[c=(n&1?n:--n)/2+1];memset(v,1,c);for(i=m=e=1;i<c;i++){for(m=i;m<c&&!v[m];)m++;if(m==c)break;e++;for(d=o=m*2+1;d<n+1;d+=o*2)v[d/2]=0;if(n<o*o)break;}for(i=1;i<c;)e+=v[i++];delete[]v;}printf("%d\n",e);}}
|
a.cc: In function 'int main()':
a.cc:3:110: error: 'memset' was not declared in this scope
3 | int main(){for(int m,n,o,c,d,e,i;!(std::cin>>n).eof();){if(n<3)e=n>1;else{bool*v=new bool[c=(n&1?n:--n)/2+1];memset(v,1,c);for(i=m=e=1;i<c;i++){for(m=i;m<c&&!v[m];)m++;if(m==c)break;e++;for(d=o=m*2+1;d<n+1;d+=o*2)v[d/2]=0;if(n<o*o)break;}for(i=1;i<c;)e+=v[i++];delete[]v;}printf("%d\n",e);}}
| ^~~~~~
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>
|
s890760455
|
p00009
|
C++
|
#include<iostream>
#include<string>
int main(){for(int m,n,o,c,d,e,i;!(std::cin>>n).eof();){if(n<3)e=n>1;else{bool*v=new bool[c=(n&1?n:--n)/2+1];memset(v,1,c);for(i=m=e=1;i<c;i++){for(m=i;m<c&&!v[m];)m++;if(m==c)break;e++;for(d=o=m*2+1;d<n+1;d+=o*2)v[d/2]=0;if(n<o*o)break;}for(i=1;i<c;)e+=v[i++];delete[]v;}printf("%d\n",e);}}
|
a.cc: In function 'int main()':
a.cc:3:110: error: 'memset' was not declared in this scope
3 | int main(){for(int m,n,o,c,d,e,i;!(std::cin>>n).eof();){if(n<3)e=n>1;else{bool*v=new bool[c=(n&1?n:--n)/2+1];memset(v,1,c);for(i=m=e=1;i<c;i++){for(m=i;m<c&&!v[m];)m++;if(m==c)break;e++;for(d=o=m*2+1;d<n+1;d+=o*2)v[d/2]=0;if(n<o*o)break;}for(i=1;i<c;)e+=v[i++];delete[]v;}printf("%d\n",e);}}
| ^~~~~~
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>
|
s792804390
|
p00009
|
C++
|
#include<iostream>
#include<string>
#include<new>
int main(){for(int m,n,o,c,d,e,i;!(std::cin>>n).eof();){if(n<3)e=n>1;else{bool*v=new bool[c=(n&1?n:--n)/2+1];memset(v,1,c);for(i=m=e=1;i<c;i++){for(m=i;m<c&&!v[m];)m++;if(m==c)break;e++;for(d=o=m*2+1;d<n+1;d+=o*2)v[d/2]=0;if(n<o*o)break;}for(i=1;i<c;)e+=v[i++];delete[]v;}printf("%d\n",e);}}
|
a.cc: In function 'int main()':
a.cc:4:110: error: 'memset' was not declared in this scope
4 | int main(){for(int m,n,o,c,d,e,i;!(std::cin>>n).eof();){if(n<3)e=n>1;else{bool*v=new bool[c=(n&1?n:--n)/2+1];memset(v,1,c);for(i=m=e=1;i<c;i++){for(m=i;m<c&&!v[m];)m++;if(m==c)break;e++;for(d=o=m*2+1;d<n+1;d+=o*2)v[d/2]=0;if(n<o*o)break;}for(i=1;i<c;)e+=v[i++];delete[]v;}printf("%d\n",e);}}
| ^~~~~~
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>
|
s868848745
|
p00009
|
C++
|
#include<iostream>
#include<string>
int main(){for(int m,n,o,c,d,e,i;!(std::cin>>n).eof();){if(n<3)e=n>1;else{bool*v=new bool[c=(n&1?n:--n)/2+1];std::memset(v,1,c);for(i=m=e=1;i<c;i++){for(m=i;m<c&&!v[m];)m++;if(m==c)break;e++;for(d=o=m*2+1;d<n+1;d+=o*2)v[d/2]=0;if(n<o*o)break;}for(i=1;i<c;)e+=v[i++];delete[]v;}printf("%d\n",e);}}
|
a.cc: In function 'int main()':
a.cc:3:115: error: 'memset' is not a member of 'std'; did you mean 'wmemset'?
3 | int main(){for(int m,n,o,c,d,e,i;!(std::cin>>n).eof();){if(n<3)e=n>1;else{bool*v=new bool[c=(n&1?n:--n)/2+1];std::memset(v,1,c);for(i=m=e=1;i<c;i++){for(m=i;m<c&&!v[m];)m++;if(m==c)break;e++;for(d=o=m*2+1;d<n+1;d+=o*2)v[d/2]=0;if(n<o*o)break;}for(i=1;i<c;)e+=v[i++];delete[]v;}printf("%d\n",e);}}
| ^~~~~~
| wmemset
|
s374781575
|
p00009
|
C++
|
#include <iostream>
using namespace std;
typedef long long ll;
int main()
{
int prime_num[1000001];
memset(prime_num, 0, 1000001);
prime_num[2] = 1;
int ans = 1;
for(int i = 3; i <= 1000000; i++) {
if(i % 2 == 0) {
prime_num[i] = prime_num[i-1];
continue;
}
bool is_prime = true;
for(int j = 3; j*j <= i; j++) {
if(i % j == 0) {
is_prime = false;
break;
}
}
if(is_prime) {
prime_num[i] = prime_num[i-1] + 1;
} else {
prime_num[i] = prime_num[i-1];
}
}
int n;
while(cin >> n) {
cout << prime_num[n] << endl;
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:10:5: error: 'memset' was not declared in this scope
10 | memset(prime_num, 0, 1000001);
| ^~~~~~
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 |
|
s065607341
|
p00009
|
C++
|
#include <iostream>
#include <math>
using namespace std;
int main() {
int lim;
int i,n;
int count=1;
bool isPrime=true;
scanf("%d",&n);
for(lim=2;lim<=n;lim++) {
for(i=2;i<(int)(sqrt(lim)+1.0);i++) {
if((lim%i)==0) {
isPrime=false;
count++;
break;
}
}
}
printf("%d",n-count);
return 0;
}
|
a.cc:2:10: fatal error: math: No such file or directory
2 | #include <math>
| ^~~~~~
compilation terminated.
|
s417300608
|
p00009
|
C++
|
#include<cstdio>
#include<cstring>
int main(){
int n,cnt=0;
scanf("%d",&n);
int a[n+1];
memset(a,-1,sizeof(int)*(n+1));
for(int i=2;i<=n;i++){
if(a[i]==-1){ con++;
for(int j=i;j<=n;j=j+i) a[j]=0;}
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:9:16: error: 'con' was not declared in this scope
9 | if(a[i]==-1){ con++;
| ^~~
|
s512019373
|
p00009
|
C++
|
#include <cstdio>
int NUM = 1000000;
bool prime[NUM];
int main(){
prime[0] = false;prime[1] = false;
for(int i=2;i<NUM;i++)prime[i] = true;
for(int i=2;i*i<NUM;i++)
for(int k=2;i*k<NUM;k++)
prime[i*k]=false;
int primeNum[NUM];
for(int i=0,c=0;i<NUM;i++){
prime[i]&&c++;
primeNum[i] = c;
}
for(int n;scanf("%d",&n)+1;printf("%d",primeNum[n]));
}
|
a.cc:3:12: error: size of array 'prime' is not an integral constant-expression
3 | bool prime[NUM];
| ^~~
|
s550479476
|
p00009
|
C++
|
#include <cstdio>
const int N = 1000000;
int p[NUM],int pN[NUM];
main(){p[0]=0;p[1]=0;int i,k,n,c;
for(i=2;i<N;i++)prime[i]=1;for(i=2;i*i<N;){for(k=2;i*k<N;k++)p[i*k]=0;do{i++;}while(!p[i]);}for(i=0,c=0;i<N;i++){p[i]&&c++;pN[i] = c;}for(;scanf("%d",&n)+1;printf("%d\n",pN[n]));}
|
a.cc:3:7: error: 'NUM' was not declared in this scope
3 | int p[NUM],int pN[NUM];
| ^~~
a.cc:3:12: error: expected unqualified-id before 'int'
3 | int p[NUM],int pN[NUM];
| ^~~
a.cc:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
4 | main(){p[0]=0;p[1]=0;int i,k,n,c;
| ^~~~
a.cc: In function 'int main()':
a.cc:4:8: error: 'p' was not declared in this scope
4 | main(){p[0]=0;p[1]=0;int i,k,n,c;
| ^
a.cc:5:17: error: 'prime' was not declared in this scope
5 | for(i=2;i<N;i++)prime[i]=1;for(i=2;i*i<N;){for(k=2;i*k<N;k++)p[i*k]=0;do{i++;}while(!p[i]);}for(i=0,c=0;i<N;i++){p[i]&&c++;pN[i] = c;}for(;scanf("%d",&n)+1;printf("%d\n",pN[n]));}
| ^~~~~
a.cc:5:124: error: 'pN' was not declared in this scope; did you mean 'N'?
5 | for(i=2;i<N;i++)prime[i]=1;for(i=2;i*i<N;){for(k=2;i*k<N;k++)p[i*k]=0;do{i++;}while(!p[i]);}for(i=0,c=0;i<N;i++){p[i]&&c++;pN[i] = c;}for(;scanf("%d",&n)+1;printf("%d\n",pN[n]));}
| ^~
| N
a.cc:5:171: error: 'pN' was not declared in this scope; did you mean 'N'?
5 | for(i=2;i<N;i++)prime[i]=1;for(i=2;i*i<N;){for(k=2;i*k<N;k++)p[i*k]=0;do{i++;}while(!p[i]);}for(i=0,c=0;i<N;i++){p[i]&&c++;pN[i] = c;}for(;scanf("%d",&n)+1;printf("%d\n",pN[n]));}
| ^~
| N
|
s559981648
|
p00009
|
C++
|
#include <cstdio>
const int N = 1000000;
int p[N],int pN[N];
main(){p[0]=0;p[1]=0;int i,k,n,c;
for(i=2;i<N;i++)prime[i]=1;for(i=2;i*i<N;){for(k=2;i*k<N;k++)p[i*k]=0;do{i++;}while(!p[i]);}for(i=0,c=0;i<N;i++){p[i]&&c++;pN[i] = c;}for(;scanf("%d",&n)+1;printf("%d\n",pN[n]));}
|
a.cc:3:10: error: expected unqualified-id before 'int'
3 | int p[N],int pN[N];
| ^~~
a.cc:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
4 | main(){p[0]=0;p[1]=0;int i,k,n,c;
| ^~~~
a.cc: In function 'int main()':
a.cc:5:17: error: 'prime' was not declared in this scope
5 | for(i=2;i<N;i++)prime[i]=1;for(i=2;i*i<N;){for(k=2;i*k<N;k++)p[i*k]=0;do{i++;}while(!p[i]);}for(i=0,c=0;i<N;i++){p[i]&&c++;pN[i] = c;}for(;scanf("%d",&n)+1;printf("%d\n",pN[n]));}
| ^~~~~
a.cc:5:124: error: 'pN' was not declared in this scope; did you mean 'p'?
5 | for(i=2;i<N;i++)prime[i]=1;for(i=2;i*i<N;){for(k=2;i*k<N;k++)p[i*k]=0;do{i++;}while(!p[i]);}for(i=0,c=0;i<N;i++){p[i]&&c++;pN[i] = c;}for(;scanf("%d",&n)+1;printf("%d\n",pN[n]));}
| ^~
| p
a.cc:5:171: error: 'pN' was not declared in this scope; did you mean 'p'?
5 | for(i=2;i<N;i++)prime[i]=1;for(i=2;i*i<N;){for(k=2;i*k<N;k++)p[i*k]=0;do{i++;}while(!p[i]);}for(i=0,c=0;i<N;i++){p[i]&&c++;pN[i] = c;}for(;scanf("%d",&n)+1;printf("%d\n",pN[n]));}
| ^~
| p
|
s683568620
|
p00009
|
C++
|
#include <iostream>
using namespace std;
#define MAX 1000000;
int N;
int prime[MAX];
int main(){
prime[0]=1;
prime[1]=1;
prime[2]=0;
prime[3]=0;
for(int i=0;i*i<=MAX;i++) {
if(prime[i]==1) continue;
for(int t = i*2;t<MAX;t+=i)
prime[i]=1;
}
while(cin.eof()){
int m = 0;
cin >> N;
for(int i =0;i<=N;i++)
if(prime[i]==0)
m++;
cout << m << endl;
}
return 0;
}
|
a.cc:3:20: error: expected ']' before ';' token
3 | #define MAX 1000000;
| ^
a.cc:6:11: note: in expansion of macro 'MAX'
6 | int prime[MAX];
| ^~~
a.cc:6:14: error: expected unqualified-id before ']' token
6 | int prime[MAX];
| ^
a.cc: In function 'int main()':
a.cc:10:9: error: 'prime' was not declared in this scope
10 | prime[0]=1;
| ^~~~~
a.cc:14:29: error: expected primary-expression before ';' token
14 | for(int i=0;i*i<=MAX;i++) {
| ^
a.cc:14:29: error: expected ')' before ';' token
14 | for(int i=0;i*i<=MAX;i++) {
| ~ ^
a.cc:14:30: error: 'i' was not declared in this scope
14 | for(int i=0;i*i<=MAX;i++) {
| ^
|
s300215021
|
p00009
|
C++
|
#include <iostream>
using namespace std;
int main(){
int a;
int i, j;
int past=1, a_sqrt;
int count;
bool chk[1000000];
for(i=1; i<1000000; i++) chk[i]=true;
while(cin>>a){
count=0;
if(past>=a){
for(i=1; i<=a; i++){
if(chk[i]) count++;
}
printf("%d\n", count);
}
else {
a_sqrt=a^0.5;
for(i=2; i<=a_sqrt; i++){
for(j=past+1; j<=a; j++){
if(j%i==0) chk[j]=false;
}
}
past=a;
for(i=1; i<=a; i++){
if(chk[i]) count++;
}
printf("%d\n", count);
}
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:21:15: error: invalid operands of types 'int' and 'double' to binary 'operator^'
21 | a_sqrt=a^0.5;
| ~^~~~
| | |
| | double
| int
|
s912143661
|
p00009
|
C++
|
#include <iostream>
using namespace std;
int main(){
int a;
int i, j;
int past=1, a_sqrt;
int count;
bool chk[1000000];
for(i=1; i<1000000; i++) chk[i]=true;
while(cin>>a){
count=0;
if(past>=a){
for(i=1; i<=a; i++){
if(chk[i]) count++;
}
printf("%d\n", count);
}
else {
a_sqrt=(int)sqrt(a);
for(i=2; i<=a_sqrt; i++){
for(j=past+1; j<=a; j++){
if(j%i==0) chk[j]=false;
}
}
past=a;
for(i=1; i<=a; i++){
if(chk[i]) count++;
}
printf("%d\n", count);
}
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:21:19: error: 'sqrt' was not declared in this scope; did you mean 'a_sqrt'?
21 | a_sqrt=(int)sqrt(a);
| ^~~~
| a_sqrt
|
s792171889
|
p00009
|
C++
|
#include <iostream>
using namespace std;
int main(){
int a;
int i, j;
int past=1, a_sqrt;
int count;
bool chk[1000000];
for(i=1; i<1000000; i++) chk[i]=true;
while(cin >> a){
count=0;
if(past>=a){
for(i=1; i<=a; i++){
if(chk[i]) count++;
}
printf("%d\n", count);
}
else {
a_sqrt=(int)sqrt(a);
for(i=2; i<=a_sqrt; i++){
for(j=past+1; j<=a; j++){
if(j%i==0) chk[j]=false;
}
}
past=a;
for(i=1; i<=a; i++){
if(chk[i]) count++;
}
printf("%d\n", count);
}
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:21:19: error: 'sqrt' was not declared in this scope; did you mean 'a_sqrt'?
21 | a_sqrt=(int)sqrt(a);
| ^~~~
| a_sqrt
|
s742641962
|
p00009
|
C++
|
import java.io.*;
import java.util.*;
import java.math.*;
class Main{
private static ArrayList<Integer> sum_check(int a){
int count = 0;
ArrayList<Integer> s = new ArrayList<Integer>();
for(int i=0;i<=a;i++){
s.add(0);
}
s.set(2,1);
for(int i=3;i<=a;i=i+2) s.set(i,1);
for(int i=3;i<=Math.sqrt(a);i=i+2){
if(s.get(i) == 0) continue;
for(int j=i+i;j<=a;j=j+i)s.set(j,0);
}
return s;
}
public static void main(String args[]) throws IOException{
Scanner scan = new Scanner(System.in);
int n,count;
ArrayList<Integer> a = new ArrayList<Integer>();
ArrayList<Integer> res = new ArrayList<Integer>();
while(scan.hasNext()){
count = 1;
String str1 = scan.next();
n = Integer.valueOf(str1).intValue();
if(n != 1){
a = sum_check(n);
for(int i=3;i<=n;i=i+2){
if(a.get(i) == 1)count++;
}
res.add(count);
}
else res.add(0);
}
for(int i=0;i<res.size();i++){
System.out.println(res.get(i));
}
}
}
|
a.cc:1:1: error: 'import' does not name a type
1 | import java.io.*;
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
3 | import java.util.*;
| ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
4 | import java.math.*;
| ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:10:16: error: expected ':' before 'static'
10 | private static ArrayList<Integer> sum_check(int a){
| ^~~~~~~
| :
a.cc:10:24: error: 'ArrayList' does not name a type
10 | private static ArrayList<Integer> sum_check(int a){
| ^~~~~~~~~
a.cc:30:23: error: expected ':' before 'static'
30 | public static void main(String args[]) throws IOException{
| ^~~~~~~
| :
a.cc:30:41: error: 'String' has not been declared
30 | public static void main(String args[]) throws IOException{
| ^~~~~~
a.cc:30:54: error: expected ';' at end of member declaration
30 | public static void main(String args[]) throws IOException{
| ^
| ;
a.cc:30:56: error: 'throws' does not name a type
30 | public static void main(String args[]) throws IOException{
| ^~~~~~
a.cc:63:2: error: expected ';' after class definition
63 | }
| ^
| ;
|
s073022942
|
p00009
|
C++
|
#include<iostream>
#include<string>
#include<cmath>
#include<time.h>
using namespace std;
int main()
{
long long int k,p[100000];
long long int n;
time_t time1,time2;
p[0]=2;
cin>>n;
time(&time1);
if(n<0){
break;
}
k=0;
int r=(int)sqrt((float)n);
for(int i=3;i<=r;i++){
for(int j=0;j<k+1;j++){
if(i%p[j]==0){
break;
}else if(j==k){
k++;
cout<<i<<endl;
p[k]=i;
}
}
}
long long int r_k=k;
for(;r<n;r++){
for(long int i=0;i<=r_k;i++){
if(r%p[i]==0){
break;
}else if(i==r_k){
k++;
cout<<r<<endl;
}
}
}
time(&time2);
if(k!=0&&k!=1){
k+=1;
cout<<k<<endl;
}else{
cout<<k<<endl;
}
}
|
a.cc: In function 'int main()':
a.cc:17:25: error: break statement not within loop or switch
17 | break;
| ^~~~~
|
s797829920
|
p00009
|
C++
|
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main()
{
long long int k,p[100000];
long long int n;
p[0]=2;
cin>>n;
if(n<0){
break;
}
k=0;
int r=(int)sqrt((float)n);
for(int i=3;i<=r;i++){
for(int j=0;j<k+1;j++){
if(i%p[j]==0){
break;
}else if(j==k){
k++;
cout<<i<<endl;
p[k]=i;
}
}
}
long long int r_k=k;
for(;r<n;r++){
for(long int i=0;i<=r_k;i++){
if(r%p[i]==0){
break;
}else if(i==r_k){
k++;
cout<<r<<endl;
}
}
}
if(k!=0&&k!=1){
k+=1;
cout<<k<<endl;
}else{
cout<<k<<endl;
}
}
|
a.cc: In function 'int main()':
a.cc:16:25: error: break statement not within loop or switch
16 | break;
| ^~~~~
|
s017787791
|
p00009
|
C++
|
j,a[' '],s;main(i){for(;++i<1e6;){if(!a[i])for(j=i;j<1e6;)a[j+=i]=1;a[i]=s+=!a[i];}for(;~scanf("%d",&i);printf("%d\n",a[i]));}
|
a.cc:1:5: warning: multi-character character constant [-Wmultichar]
1 | j,a[' '],s;main(i){for(;++i<1e6;){if(!a[i])for(j=i;j<1e6;)a[j+=i]=1;a[i]=s+=!a[i];}for(;~scanf("%d",&i);printf("%d\n",a[i]));}
| ^~~~~
a.cc:1:1: error: 'j' does not name a type
1 | j,a[' '],s;main(i){for(;++i<1e6;){if(!a[i])for(j=i;j<1e6;)a[j+=i]=1;a[i]=s+=!a[i];}for(;~scanf("%d",&i);printf("%d\n",a[i]));}
| ^
a.cc:1:18: error: expected constructor, destructor, or type conversion before '(' token
1 | j,a[' '],s;main(i){for(;++i<1e6;){if(!a[i])for(j=i;j<1e6;)a[j+=i]=1;a[i]=s+=!a[i];}for(;~scanf("%d",&i);printf("%d\n",a[i]));}
| ^
|
s335623308
|
p00009
|
C++
|
j,a[' '],s;main(i){for(;++i<1e6||~scanf("%d",&j)&&printf("%d\n",a[j]);)for(s+=!a[j=i];j<1e6;a[i]=s)a[j+=i]=1;}
|
a.cc:1:5: warning: multi-character character constant [-Wmultichar]
1 | j,a[' '],s;main(i){for(;++i<1e6||~scanf("%d",&j)&&printf("%d\n",a[j]);)for(s+=!a[j=i];j<1e6;a[i]=s)a[j+=i]=1;}
| ^~~~~
a.cc:1:1: error: 'j' does not name a type
1 | j,a[' '],s;main(i){for(;++i<1e6||~scanf("%d",&j)&&printf("%d\n",a[j]);)for(s+=!a[j=i];j<1e6;a[i]=s)a[j+=i]=1;}
| ^
a.cc:1:18: error: expected constructor, destructor, or type conversion before '(' token
1 | j,a[' '],s;main(i){for(;++i<1e6||~scanf("%d",&j)&&printf("%d\n",a[j]);)for(s+=!a[j=i];j<1e6;a[i]=s)a[j+=i]=1;}
| ^
|
s270113248
|
p00009
|
C++
|
j,a[' '],s;main(i){for(;++i<1e6||~scanf(s="%d\n",&j)&&printf(s,a[j]);)for(a[i]=s+=!a[j=i];j<1e6;a[j+=i]=1);}
|
a.cc:1:5: warning: multi-character character constant [-Wmultichar]
1 | j,a[' '],s;main(i){for(;++i<1e6||~scanf(s="%d\n",&j)&&printf(s,a[j]);)for(a[i]=s+=!a[j=i];j<1e6;a[j+=i]=1);}
| ^~~~~
a.cc:1:1: error: 'j' does not name a type
1 | j,a[' '],s;main(i){for(;++i<1e6||~scanf(s="%d\n",&j)&&printf(s,a[j]);)for(a[i]=s+=!a[j=i];j<1e6;a[j+=i]=1);}
| ^
a.cc:1:18: error: expected constructor, destructor, or type conversion before '(' token
1 | j,a[' '],s;main(i){for(;++i<1e6||~scanf(s="%d\n",&j)&&printf(s,a[j]);)for(a[i]=s+=!a[j=i];j<1e6;a[j+=i]=1);}
| ^
|
s151665737
|
p00009
|
C++
|
#include<iostream>
using namespace std;
int main(){
int n;
int max=1;
while(cin>>n){
for(int i=3;i<=n;i+=2){
for(int j=2;j<=i/2+1;j++){
if(i%j==0){max++;goto A;}
}
A:
;
cout<<max<<endl;
max=1;
}
}
|
a.cc: In function 'int main()':
a.cc:16:2: error: expected '}' at end of input
16 | }
| ^
a.cc:3:11: note: to match this '{'
3 | int main(){
| ^
|
s695663079
|
p00009
|
C++
|
j,a[' '],s;main(i){for(;++i<1e6||~scanf(s="%d\n",&j)&&printf(s,a[j]);)for(a[i]=s+=!a[j=i];j<1e6;a[j+=i]=1);}
|
a.cc:1:5: warning: multi-character character constant [-Wmultichar]
1 | j,a[' '],s;main(i){for(;++i<1e6||~scanf(s="%d\n",&j)&&printf(s,a[j]);)for(a[i]=s+=!a[j=i];j<1e6;a[j+=i]=1);}
| ^~~~~
a.cc:1:1: error: 'j' does not name a type
1 | j,a[' '],s;main(i){for(;++i<1e6||~scanf(s="%d\n",&j)&&printf(s,a[j]);)for(a[i]=s+=!a[j=i];j<1e6;a[j+=i]=1);}
| ^
a.cc:1:18: error: expected constructor, destructor, or type conversion before '(' token
1 | j,a[' '],s;main(i){for(;++i<1e6||~scanf(s="%d\n",&j)&&printf(s,a[j]);)for(a[i]=s+=!a[j=i];j<1e6;a[j+=i]=1);}
| ^
|
s435274644
|
p00009
|
C++
|
j,a[' '],s;main(i){for(;++i<1e6||~scanf(s="%d\n",&j)&&printf(s,a[j]);)for(a[i]=s+=!a[j=i];j<1e6;a[j+=i]=1);}
|
a.cc:1:5: warning: multi-character character constant [-Wmultichar]
1 | j,a[' '],s;main(i){for(;++i<1e6||~scanf(s="%d\n",&j)&&printf(s,a[j]);)for(a[i]=s+=!a[j=i];j<1e6;a[j+=i]=1);}
| ^~~~~
a.cc:1:1: error: 'j' does not name a type
1 | j,a[' '],s;main(i){for(;++i<1e6||~scanf(s="%d\n",&j)&&printf(s,a[j]);)for(a[i]=s+=!a[j=i];j<1e6;a[j+=i]=1);}
| ^
a.cc:1:18: error: expected constructor, destructor, or type conversion before '(' token
1 | j,a[' '],s;main(i){for(;++i<1e6||~scanf(s="%d\n",&j)&&printf(s,a[j]);)for(a[i]=s+=!a[j=i];j<1e6;a[j+=i]=1);}
| ^
|
s268080664
|
p00009
|
C++
|
#include <iostream>
#include <cstdlib>
using namespace std;
bool is_prime(int n){
for(int i=2;i*i<=n;i++){
if(n % i == 0) return false;
}
return n!=1;
}
int main(){
int n;
while(~scanf("%d",&n)){
int* table = new int[1000000];
memset(table,sizeof(table),1);
table[0]=0;
for(int i=1;i<=n;i++){
if(!is_prime(i)) {
for(int j=i;j<=n;j*=i){
table[j] = 0;
}
}
}
printf("%d\n",count(table,table+1000000,1));
}
}
|
a.cc: In function 'int main()':
a.cc:17:1: error: 'memset' was not declared in this scope
17 | memset(table,sizeof(table),1);
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include <cstdlib>
+++ |+#include <cstring>
3 | using namespace std;
a.cc:27:15: error: 'count' was not declared in this scope
27 | printf("%d\n",count(table,table+1000000,1));
| ^~~~~
|
s478597239
|
p00009
|
C++
|
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <limits>
#include <map>
using namespace std;
bool is_prime(int n){
for(int i=2;i*i<=n;i++){
if(n % i == 0) return false;
}
return n!=1;
}
int main(){
int n;
while(~scanf("%d",&n)){
int* table = new int[1000000];
memset(table,sizeof(table),1);
table[0]=0;
for(int i=1;i<=n;i++){
if(!is_prime(i)) {
for(int j=i;j<=n;j*=i){
table[j] = 0;
}
}
}
printf("%d\n",count(table,table+1000000,1));
}
}
|
a.cc: In function 'int main()':
a.cc:22:1: error: 'memset' was not declared in this scope
22 | memset(table,sizeof(table),1);
| ^~~~~~
a.cc:8:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
7 | #include <map>
+++ |+#include <cstring>
8 | using namespace std;
|
s339638879
|
p00009
|
C++
|
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <limits>
#include <map>
#include <string>
using namespace std;
bool is_prime(int n){
for(int i=2;i*i<=n;i++){
if(n % i == 0) return false;
}
return n!=1;
}
int main(){
int n;
while(~scanf("%d",&n)){
int* table = new int[1000000];
memset(table,sizeof(table),1);
table[0]=0;
for(int i=1;i<=n;i++){
if(!is_prime(i)) {
for(int j=i;j<=n;j*=i){
table[j] = 0;
}
}
}
printf("%d\n",count(table,table+1000000,1));
}
}
|
a.cc: In function 'int main()':
a.cc:23:1: error: 'memset' was not declared in this scope
23 | memset(table,sizeof(table),1);
| ^~~~~~
a.cc:8:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
7 | #include <map>
+++ |+#include <cstring>
8 | #include <string>
|
s277461425
|
p00009
|
C++
|
#include<iostream>
using namespace std;
int main(void){
long int n,f,k,i;
int count;
bool chk;
scanf("%d",&n)!=EOF);
count=0;
for(i=2;i<=n;i++){
chk=0;
f=i/2;
k=2;
while(f>=k){
if((i%k)==0){
chk=true;
break;
}
k++;
}
if(chk==false){
count++;
}
}
cout<<count<<endl;
}
|
a.cc: In function 'int main()':
a.cc:10:28: error: expected ';' before ')' token
10 | scanf("%d",&n)!=EOF);
| ^
|
s274128509
|
p00009
|
C++
|
#include <iostream>
#include <string>
#include <array>
 
int main() {
    std::array<bool, 1000000> is_prime_table = { false, false, true };
    for( int i=3; i<=is_prime_table.size(); i+=2 ) {
        is_prime_table[i] = [&i]() -> bool
        {
            for( int j=3; j*j<=i; j+=2 )
                if ( i % j == 0 )
                    return false;
            return true;
        }();
    }
     
    int num = 0;
    while( std::cin >> num ) {
        int result = num > 1 ? 1 : 0;    // 2
         
        for( int i=3; i<=num; i+=2 )
            if ( is_prime_table[i] )
                ++result;
 
        std::cout << result << std::endl;
    }
}
|
a.cc:4:2: error: stray '#' in program
4 |  
| ^
a.cc:6:2: error: stray '#' in program
6 |     std::array<bool, 1000000> is_prime_table = { false, false, true };
| ^
a.cc:6:8: error: stray '#' in program
6 |     std::array<bool, 1000000> is_prime_table = { false, false, true };
| ^
a.cc:6:14: error: stray '#' in program
6 |     std::array<bool, 1000000> is_prime_table = { false, false, true };
| ^
a.cc:6:20: error: stray '#' in program
6 |     std::array<bool, 1000000> is_prime_table = { false, false, true };
| ^
a.cc:7:2: error: stray '#' in program
7 |     for( int i=3; i<=is_prime_table.size(); i+=2 ) {
| ^
a.cc:7:8: error: stray '#' in program
7 |     for( int i=3; i<=is_prime_table.size(); i+=2 ) {
| ^
a.cc:7:14: error: stray '#' in program
7 |     for( int i=3; i<=is_prime_table.size(); i+=2 ) {
| ^
a.cc:7:20: error: stray '#' in program
7 |     for( int i=3; i<=is_prime_table.size(); i+=2 ) {
| ^
a.cc:8:2: error: stray '#' in program
8 |         is_prime_table[i] = [&i]() -> bool
| ^
a.cc:8:8: error: stray '#' in program
8 |         is_prime_table[i] = [&i]() -> bool
| ^
a.cc:8:14: error: stray '#' in program
8 |         is_prime_table[i] = [&i]() -> bool
| ^
a.cc:8:20: error: stray '#' in program
8 |         is_prime_table[i] = [&i]() -> bool
| ^
a.cc:8:26: error: stray '#' in program
8 |         is_prime_table[i] = [&i]() -> bool
| ^
a.cc:8:32: error: stray '#' in program
8 |         is_prime_table[i] = [&i]() -> bool
| ^
a.cc:8:38: error: stray '#' in program
8 |         is_prime_table[i] = [&i]() -> bool
| ^
a.cc:8:44: error: stray '#' in program
8 |         is_prime_table[i] = [&i]() -> bool
| ^
a.cc:9:2: error: stray '#' in program
9 |         {
| ^
a.cc:9:8: error: stray '#' in program
9 |         {
| ^
a.cc:9:14: error: stray '#' in program
9 |         {
| ^
a.cc:9:20: error: stray '#' in program
9 |         {
| ^
a.cc:9:26: error: stray '#' in program
9 |         {
| ^
a.cc:9:32: error: stray '#' in program
9 |         {
| ^
a.cc:9:38: error: stray '#' in program
9 |         {
| ^
a.cc:9:44: error: stray '#' in program
9 |         {
| ^
a.cc:10:2: error: stray '#' in program
10 |             for( int j=3; j*j<=i; j+=2 )
| ^
a.cc:10:8: error: stray '#' in program
10 |             for( int j=3; j*j<=i; j+=2 )
| ^
a.cc:10:14: error: stray '#' in program
10 |             for( int j=3; j*j<=i; j+=2 )
| ^
a.cc:10:20: error: stray '#' in program
10 |             for( int j=3; j*j<=i; j+=2 )
| ^
a.cc:10:26: error: stray '#' in program
10 |             for( int j=3; j*j<=i; j+=2 )
| ^
a.cc:10:32: error: stray '#' in program
10 |             for( int j=3; j*j<=i; j+=2 )
| ^
a.cc:10:38: error: stray '#' in program
10 |             for( int j=3; j*j<=i; j+=2 )
| ^
a.cc:10:44: error: stray '#' in program
10 |             for( int j=3; j*j<=i; j+=2 )
| ^
a.cc:10:50: error: stray '#' in program
10 |             for( int j=3; j*j<=i; j+=2 )
| ^
a.cc:10:56: error: stray '#' in program
10 |             for( int j=3; j*j<=i; j+=2 )
| ^
a.cc:10:62: error: stray '#' in program
10 |             for( int j=3; j*j<=i; j+=2 )
| ^
a.cc:10:68: error: stray '#' in program
10 |             for( int j=3; j*j<=i; j+=2 )
| ^
a.cc:11:2: error: stray '#' in program
11 |                 if ( i % j == 0 )
| ^
a.cc:11:8: error: stray '#' in program
11 |                 if ( i % j == 0 )
| ^
a.cc:11:14: error: stray '#' in program
11 |                 if ( i % j == 0 )
| ^
a.cc:11:20: error: stray '#' in program
11 |                 if ( i % j == 0 )
| ^
a.cc:11:26: error: stray '#' in program
11 |                 if ( i % j == 0 )
| ^
a.cc:11:32: error: stray '#' in program
11 |                 if ( i % j == 0 )
| ^
a.cc:11:38: error: stray '#' in program
11 |                 if ( i % j == 0 )
| ^
a.cc:11:44: error: stray '#' in program
11 |                 if ( i % j == 0 )
| ^
a.cc:11:50: error: stray '#' in program
11 |                 if ( i % j == 0 )
| ^
a.cc:11:56: error: stray '#' in program
11 |                 if ( i % j == 0 )
| ^
a.cc:11:62: error: stray '#' in program
11 |                 if ( i % j == 0 )
| ^
a.cc:11:68: error: stray '#' in program
11 |                 if ( i % j == 0 )
| ^
a.cc:11:74: error: stray '#' in program
11 |                 if ( i % j == 0 )
| ^
a.cc:11:80: error: stray '#' in program
11 |                 if ( i % j == 0 )
| ^
a.cc:11:86: error: stray '#' in program
11 |                 if ( i % j == 0 )
| ^
a.cc:11:92: error: stray '#' in program
11 |                 if ( i % j == 0 )
| ^
a.cc:12:2: error: stray '#' in program
12 |                     return false;
| ^
a.cc:12:8: error: stray '#' in program
12 |                     return false;
| ^
a.cc:12:14: error: stray '#' in program
12 |                     return false;
| ^
a.cc:12:20: error: stray '#' in program
12 |                     return false;
| ^
a.cc:12:26: error: stray '#' in program
12 |   
|
s291172549
|
p00009
|
C++
|
#include <iostream>
#include <string>
#include <array>
 
int main() {
    std::array<bool, 1000000> is_prime_table = { false, false, true };
    for( int i=3; i<=is_prime_table.size(); i+=2 ) {
        is_prime_table[i] = [&i]() -> bool
        {
            for( int j=3; j*j<=i; j+=2 )
                if ( i % j == 0 )
                    return false;
            return true;
        }();
    }
     
    int num = 0;
    while( std::cin >> num ) {
        int result = num > 1 ? 1 : 0;    // 2
         
        for( int i=3; i<=num; i+=2 )
            if ( is_prime_table[i] )
                ++result;
 
        std::cout << result << std::endl;
    }
}
|
a.cc:4:2: error: stray '#' in program
4 |  
| ^
a.cc:6:2: error: stray '#' in program
6 |     std::array<bool, 1000000> is_prime_table = { false, false, true };
| ^
a.cc:6:8: error: stray '#' in program
6 |     std::array<bool, 1000000> is_prime_table = { false, false, true };
| ^
a.cc:6:14: error: stray '#' in program
6 |     std::array<bool, 1000000> is_prime_table = { false, false, true };
| ^
a.cc:6:20: error: stray '#' in program
6 |     std::array<bool, 1000000> is_prime_table = { false, false, true };
| ^
a.cc:7:2: error: stray '#' in program
7 |     for( int i=3; i<=is_prime_table.size(); i+=2 ) {
| ^
a.cc:7:8: error: stray '#' in program
7 |     for( int i=3; i<=is_prime_table.size(); i+=2 ) {
| ^
a.cc:7:14: error: stray '#' in program
7 |     for( int i=3; i<=is_prime_table.size(); i+=2 ) {
| ^
a.cc:7:20: error: stray '#' in program
7 |     for( int i=3; i<=is_prime_table.size(); i+=2 ) {
| ^
a.cc:8:2: error: stray '#' in program
8 |         is_prime_table[i] = [&i]() -> bool
| ^
a.cc:8:8: error: stray '#' in program
8 |         is_prime_table[i] = [&i]() -> bool
| ^
a.cc:8:14: error: stray '#' in program
8 |         is_prime_table[i] = [&i]() -> bool
| ^
a.cc:8:20: error: stray '#' in program
8 |         is_prime_table[i] = [&i]() -> bool
| ^
a.cc:8:26: error: stray '#' in program
8 |         is_prime_table[i] = [&i]() -> bool
| ^
a.cc:8:32: error: stray '#' in program
8 |         is_prime_table[i] = [&i]() -> bool
| ^
a.cc:8:38: error: stray '#' in program
8 |         is_prime_table[i] = [&i]() -> bool
| ^
a.cc:8:44: error: stray '#' in program
8 |         is_prime_table[i] = [&i]() -> bool
| ^
a.cc:9:2: error: stray '#' in program
9 |         {
| ^
a.cc:9:8: error: stray '#' in program
9 |         {
| ^
a.cc:9:14: error: stray '#' in program
9 |         {
| ^
a.cc:9:20: error: stray '#' in program
9 |         {
| ^
a.cc:9:26: error: stray '#' in program
9 |         {
| ^
a.cc:9:32: error: stray '#' in program
9 |         {
| ^
a.cc:9:38: error: stray '#' in program
9 |         {
| ^
a.cc:9:44: error: stray '#' in program
9 |         {
| ^
a.cc:10:2: error: stray '#' in program
10 |             for( int j=3; j*j<=i; j+=2 )
| ^
a.cc:10:8: error: stray '#' in program
10 |             for( int j=3; j*j<=i; j+=2 )
| ^
a.cc:10:14: error: stray '#' in program
10 |             for( int j=3; j*j<=i; j+=2 )
| ^
a.cc:10:20: error: stray '#' in program
10 |             for( int j=3; j*j<=i; j+=2 )
| ^
a.cc:10:26: error: stray '#' in program
10 |             for( int j=3; j*j<=i; j+=2 )
| ^
a.cc:10:32: error: stray '#' in program
10 |             for( int j=3; j*j<=i; j+=2 )
| ^
a.cc:10:38: error: stray '#' in program
10 |             for( int j=3; j*j<=i; j+=2 )
| ^
a.cc:10:44: error: stray '#' in program
10 |             for( int j=3; j*j<=i; j+=2 )
| ^
a.cc:10:50: error: stray '#' in program
10 |             for( int j=3; j*j<=i; j+=2 )
| ^
a.cc:10:56: error: stray '#' in program
10 |             for( int j=3; j*j<=i; j+=2 )
| ^
a.cc:10:62: error: stray '#' in program
10 |             for( int j=3; j*j<=i; j+=2 )
| ^
a.cc:10:68: error: stray '#' in program
10 |             for( int j=3; j*j<=i; j+=2 )
| ^
a.cc:11:2: error: stray '#' in program
11 |                 if ( i % j == 0 )
| ^
a.cc:11:8: error: stray '#' in program
11 |                 if ( i % j == 0 )
| ^
a.cc:11:14: error: stray '#' in program
11 |                 if ( i % j == 0 )
| ^
a.cc:11:20: error: stray '#' in program
11 |                 if ( i % j == 0 )
| ^
a.cc:11:26: error: stray '#' in program
11 |                 if ( i % j == 0 )
| ^
a.cc:11:32: error: stray '#' in program
11 |                 if ( i % j == 0 )
| ^
a.cc:11:38: error: stray '#' in program
11 |                 if ( i % j == 0 )
| ^
a.cc:11:44: error: stray '#' in program
11 |                 if ( i % j == 0 )
| ^
a.cc:11:50: error: stray '#' in program
11 |                 if ( i % j == 0 )
| ^
a.cc:11:56: error: stray '#' in program
11 |                 if ( i % j == 0 )
| ^
a.cc:11:62: error: stray '#' in program
11 |                 if ( i % j == 0 )
| ^
a.cc:11:68: error: stray '#' in program
11 |                 if ( i % j == 0 )
| ^
a.cc:11:74: error: stray '#' in program
11 |                 if ( i % j == 0 )
| ^
a.cc:11:80: error: stray '#' in program
11 |                 if ( i % j == 0 )
| ^
a.cc:11:86: error: stray '#' in program
11 |                 if ( i % j == 0 )
| ^
a.cc:11:92: error: stray '#' in program
11 |                 if ( i % j == 0 )
| ^
a.cc:12:2: error: stray '#' in program
12 |                     return false;
| ^
a.cc:12:8: error: stray '#' in program
12 |                     return false;
| ^
a.cc:12:14: error: stray '#' in program
12 |                     return false;
| ^
a.cc:12:20: error: stray '#' in program
12 |                     return false;
| ^
a.cc:12:26: error: stray '#' in program
12 |   
|
s869188105
|
p00009
|
C++
|
#include<iostream>
using namespace std;
bool Prime(int n)
{
if((n==1)||(n==0))
{
return false;
}
for(int i=2;i<=n-1;++i)
{
if(n%i==0)
{
return false;
}
}
return true;
}
void main()
{
int n;
while(cin>>n)
{
int count = 0;
for(int i=0;i<=n;++i)
{
if(Prime(i))
{
++count;
}
}
cout<<count<<endl;
}
}
|
a.cc:23:1: error: '::main' must return 'int'
23 | void main()
| ^~~~
|
s004711801
|
p00009
|
C++
|
#include<iostream>
using namespace std;
bool Prime(int n)
{
if((n==1)||(n==0))
{
return false;
}
for(int i=2;i<=(int)sqrt((double)n);++i)
{
if(n%i==0)
{
return false;
}
}
return true;
}
int main()
{
int n;
while(cin>>n)
{
int count = 0;
for(int i=0;i<=n;++i)
{
if(Prime(i))
{
++count;
}
}
cout<<count<<endl;
}
return 0;
}
|
a.cc: In function 'bool Prime(int)':
a.cc:13:29: error: 'sqrt' was not declared in this scope
13 | for(int i=2;i<=(int)sqrt((double)n);++i)
| ^~~~
|
s919820776
|
p00009
|
C++
|
#include<iostream>
using namespace std;
__forceinline int isPrime(int n){
//sieve of Eratosthenes
if(n==2) return 1;
if(n%2==0 || n<2){
return 0;
}
for(int i=3; i*i<=n; i+=2){
if(n%i==0){
return 0;
}
}
return 1;
}
//0009
int main()
{
int n;
while(cin >> n){
int cnt = 0;
for(; n>1; n--){
if(isPrime(n))
++cnt;
}
cout << cnt << endl;
}
return 0;
}
|
a.cc:4:1: error: '__forceinline' does not name a type
4 | __forceinline int isPrime(int n){
| ^~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:28:28: error: 'isPrime' was not declared in this scope
28 | if(isPrime(n))
| ^~~~~~~
|
s814921453
|
p00009
|
C++
|
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
bool t[1000000];
int main(){
memset(t,1,sizeof(t));
t[0] = t[1] = false;
for(int i = 2; i < 1000; i++){
if(t[i])
for(int j = 2 * i; j < 1000000; j += i){
t[j] = false;
}
}
int n;
while(cin>>n){
int ans = 0;
for (int i = 0; i <= n; i++)
{
ans += t[i];
}
cout << ans << endl;
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:12:9: error: 'memset' was not declared in this scope
12 | memset(t,1,sizeof(t));
| ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
4 | #include <cmath>
+++ |+#include <cstring>
5 | #include <string>
|
s107805280
|
p00009
|
C++
|
#include <stdio.h>
bool isPrimeNumber(int number){
if(number == 2) return true;
if(number % 2 == 0) return false;
for(int i = 3; i <= sqrt(number) ;i += 2){
if(number % i == 0) return false;
}
return true;
}
int main(int argc, char** argv){
int search, counter;
while((scanf("%d", &search)) != EOF){
counter = 0;
for(int i = 2; i <= search; i++){
counter += isPrimeNumber(i) ? 1 : 0;
}
printf("%d\n", counter);
}
return 0;
}
|
a.cc: In function 'bool isPrimeNumber(int)':
a.cc:7:29: error: 'sqrt' was not declared in this scope
7 | for(int i = 3; i <= sqrt(number) ;i += 2){
| ^~~~
|
s406039192
|
p00009
|
C++
|
#include<stdio.h>
#include<float.h>
#include<vector>
vector<int> primes;
int ref_max=2;
int makePrimenumbers(int a){
if(a<ref_max)return 0;
temp = ref_max;
ref_max=a;
int i,k,isp=1;
for(k=temp;k<ref_max;k++){
for(i=0;i<primes.size();i++){
if(k%primes[i]==0){
isp=0;
break;
}
}
if(isp==1){
primes.push_back(k);
}
isp=1;
}
return 0;
}
int countprime(int a){
int i;
for(i=0;i<prime.size();i++)
if(a<prime[i])
break;
return (i);
}
int main(void)
{
int result;
while(scanf("%d",&a)!=EOF){
makePrimenumbers(a);
result = countprime(a);
printf("%d\n",result);
}
return 0;
}
|
a.cc:6:1: error: 'vector' does not name a type
6 | vector<int> primes;
| ^~~~~~
a.cc: In function 'int makePrimenumbers(int)':
a.cc:12:9: error: 'temp' was not declared in this scope; did you mean 'tempnam'?
12 | temp = ref_max;
| ^~~~
| tempnam
a.cc:17:27: error: 'primes' was not declared in this scope
17 | for(i=0;i<primes.size();i++){
| ^~~~~~
a.cc:24:25: error: 'primes' was not declared in this scope
24 | primes.push_back(k);
| ^~~~~~
a.cc: In function 'int countprime(int)':
a.cc:33:19: error: 'prime' was not declared in this scope
33 | for(i=0;i<prime.size();i++)
| ^~~~~
a.cc: In function 'int main()':
a.cc:42:27: error: 'a' was not declared in this scope
42 | while(scanf("%d",&a)!=EOF){
| ^
|
s802997737
|
p00009
|
C++
|
#include<stdio.h>
#include<float.h>
#include<vector>
vector<int> primes;
int ref_max=2;
int makePrimenumbers(int a){
if(a<ref_max)return 0;
temp = ref_max;
ref_max=a;
int i,k,isp=1;
for(k=temp;k<ref_max;k++){
for(i=0;i<primes.size();i++){
if(k%primes[i]==0){
isp=0;
break;
}
}
if(isp==1){
primes.push_back(k);
}
isp=1;
}
return 0;
}
int countprime(int a){
int i;
for(i=0;i<prime.size();i++)
if(a<prime[i])
break;
return (i);
}
int main(void)
{
int result;
while(scanf("%d",&a)!=EOF){
makePrimenumbers(a);
result = countprime(a);
printf("%d\n",result);
}
return 0;
}
|
a.cc:6:1: error: 'vector' does not name a type
6 | vector<int> primes;
| ^~~~~~
a.cc: In function 'int makePrimenumbers(int)':
a.cc:12:9: error: 'temp' was not declared in this scope; did you mean 'tempnam'?
12 | temp = ref_max;
| ^~~~
| tempnam
a.cc:17:27: error: 'primes' was not declared in this scope
17 | for(i=0;i<primes.size();i++){
| ^~~~~~
a.cc:24:25: error: 'primes' was not declared in this scope
24 | primes.push_back(k);
| ^~~~~~
a.cc: In function 'int countprime(int)':
a.cc:33:19: error: 'prime' was not declared in this scope
33 | for(i=0;i<prime.size();i++)
| ^~~~~
a.cc: In function 'int main()':
a.cc:42:27: error: 'a' was not declared in this scope
42 | while(scanf("%d",&a)!=EOF){
| ^
|
s688237684
|
p00009
|
C++
|
#include<stdio.h>
#include<float.h>
#include<vector>
int makePrimenumbers(int a){
int temp;
if(a<ref_max)return 0;
temp = ref_max;
ref_max=a;
int i,k,isp=1;
for(k=temp;k<ref_max;k++){
for(i=0;i<primes.size();i++){
if(k%primes[i]==0){
isp=0;
break;
}
}
if(isp==1){
primes.push_back(k);
}
isp=1;
}
return 0;
}
int countprime(int a){
int i;
for(i=0;i<prime.size();i++)
if(a<prime[i])
break;
return (i);
}
int main(void)
{
vector<int> primes;
int ref_max=2;
int result;
int a;
while(scanf("%d",&a)!=EOF){
makePrimenumbers(a);
result = countprime(a);
printf("%d\n",result);
}
return 0;
}
|
a.cc: In function 'int makePrimenumbers(int)':
a.cc:10:14: error: 'ref_max' was not declared in this scope
10 | if(a<ref_max)return 0;
| ^~~~~~~
a.cc:12:16: error: 'ref_max' was not declared in this scope
12 | temp = ref_max;
| ^~~~~~~
a.cc:17:27: error: 'primes' was not declared in this scope
17 | for(i=0;i<primes.size();i++){
| ^~~~~~
a.cc:24:25: error: 'primes' was not declared in this scope
24 | primes.push_back(k);
| ^~~~~~
a.cc: In function 'int countprime(int)':
a.cc:33:19: error: 'prime' was not declared in this scope
33 | for(i=0;i<prime.size();i++)
| ^~~~~
a.cc: In function 'int main()':
a.cc:41:9: error: 'vector' was not declared in this scope
41 | vector<int> primes;
| ^~~~~~
a.cc:41:9: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
from a.cc:3:
/usr/include/c++/14/bits/stl_vector.h:428:11: note: 'std::vector'
428 | class vector : protected _Vector_base<_Tp, _Alloc>
| ^~~~~~
/usr/include/c++/14/vector:93:13: note: 'std::pmr::vector'
93 | using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
| ^~~~~~
a.cc:41:16: error: expected primary-expression before 'int'
41 | vector<int> primes;
| ^~~
|
s875236132
|
p00009
|
C++
|
#include<stdio.h>
#include<float.h>
#include<vector>
int makePrimenumbers(int a, int ref_max, vector<int> primes){
int temp;
if(a<ref_max)return 0;
temp = ref_max;
ref_max=a;
int i,k,isp=1;
for(k=temp;k<ref_max;k++){
for(i=0;i<primes.size();i++){
if(k%primes[i]==0){
isp=0;
break;
}
}
if(isp==1){
primes.push_back(k);
}
isp=1;
}
return 0;
}
int countprime(int a, voctor<int> primes){
int i;
for(i=0;i<prime.size();i++)
if(a<prime[i])
break;
return (i);
}
int main(void)
{
vector<int> primes;
int ref_max=2;
int result;
int a;
while(scanf("%d",&a)!=EOF){
makePrimenumbers(a, max_ref, primes);
result = countprime(a, primes);
printf("%d\n",result);
}
return 0;
}
|
a.cc:7:42: error: 'vector' has not been declared
7 | int makePrimenumbers(int a, int ref_max, vector<int> primes){
| ^~~~~~
a.cc:7:48: error: expected ',' or '...' before '<' token
7 | int makePrimenumbers(int a, int ref_max, vector<int> primes){
| ^
a.cc: In function 'int makePrimenumbers(int, int, int)':
a.cc:17:27: error: 'primes' was not declared in this scope
17 | for(i=0;i<primes.size();i++){
| ^~~~~~
a.cc:24:25: error: 'primes' was not declared in this scope
24 | primes.push_back(k);
| ^~~~~~
a.cc: At global scope:
a.cc:31:23: error: 'voctor' has not been declared
31 | int countprime(int a, voctor<int> primes){
| ^~~~~~
a.cc:31:29: error: expected ',' or '...' before '<' token
31 | int countprime(int a, voctor<int> primes){
| ^
a.cc: In function 'int countprime(int, int)':
a.cc:33:19: error: 'prime' was not declared in this scope
33 | for(i=0;i<prime.size();i++)
| ^~~~~
a.cc: In function 'int main()':
a.cc:41:9: error: 'vector' was not declared in this scope
41 | vector<int> primes;
| ^~~~~~
a.cc:41:9: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
from a.cc:3:
/usr/include/c++/14/bits/stl_vector.h:428:11: note: 'std::vector'
428 | class vector : protected _Vector_base<_Tp, _Alloc>
| ^~~~~~
/usr/include/c++/14/vector:93:13: note: 'std::pmr::vector'
93 | using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
| ^~~~~~
a.cc:41:16: error: expected primary-expression before 'int'
41 | vector<int> primes;
| ^~~
a.cc:46:37: error: 'max_ref' was not declared in this scope
46 | makePrimenumbers(a, max_ref, primes);
| ^~~~~~~
a.cc:46:46: error: 'primes' was not declared in this scope
46 | makePrimenumbers(a, max_ref, primes);
| ^~~~~~
|
s706834448
|
p00009
|
C++
|
#include <iostream>
using namespace std;
int main(){
int n;
int a=0;
cin >> n)
for(int i = 0; i < n; ++i){
for(int j = 2; j <= i; ++j){
if(i%j == 0){
if(i==j){
++a;
}else{
break;
}
}
}
}
cout << a << '\n';
}
|
a.cc: In function 'int main()':
a.cc:7:17: error: expected ';' before ')' token
7 | cin >> n)
| ^
| ;
a.cc:8:32: error: 'i' was not declared in this scope
8 | for(int i = 0; i < n; ++i){
| ^
|
s166134423
|
p00009
|
C++
|
#include<iostream>
bool sieve[1000000];
void makesieve();
int main()
{
makesieve();
while(1)
{
int n,ans=0;
std::cin>>n;
if(std::cin.eof())break;
for(int i=0;i<n;i++)
{
ans+=sieve[i]?1:0;
}
std::cout<<ans<<std::endl;
}
return 0;
}
void makesieve()
{
memset(sieve,-1,sizeof(sieve));
sieve[0]=false;sieve[1]=false;
for(int i=2;i<1000000;i++)
{
for(int j=i*2;j<1000000;j+=i)
{
sieve[j]=false;
}
}
}
|
a.cc: In function 'void makesieve()':
a.cc:26:9: error: 'memset' was not declared in this scope
26 | memset(sieve,-1,sizeof(sieve));
| ^~~~~~
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 |
|
s679248051
|
p00009
|
C++
|
import java.util.Scanner;
public class Main
{
public static void main(String arg[])
{
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int count=0;
for (int i=2; i<=n; i++)
{
if(prim(i))
count++;
}
System.out.println(count);
}
public static boolean prim(int a)
{
if(a<2)
return false;
else if (a==2)
return true;
for(int j = 2; j<a; j++)
{
if(a%j==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:3:1: error: expected unqualified-id before 'public'
3 | public class Main
| ^~~~~~
|
s188185121
|
p00009
|
C++
|
#include<stdio.h>
#define max 1000001;
int main(void)
{
int *d, f1, f2, n, cnt;
d = new int [max];
for(f1 = 0; f1 < max; f1++)
{
d[f1] = 1;
}
for(f1 = 2; f1 *f1 < max; f1++)
{
if(d[f1] == 1)
{
for(f2 = 2 * f1; f2 < max; f2 += f1)
{
d[f2] = 0;
}
}
}
while (scanf("%d",&n) != EOF)
{
cnt= 0;
for(f1 = 2; f1 >= n; f1++)
{
if(d[f1] == 1)
cnt++;
}
printf("%d\n",cnt);
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:2:20: error: expected ']' before ';' token
2 | #define max 1000001;
| ^
a.cc:7:22: note: in expansion of macro 'max'
7 | d = new int [max];
| ^~~
a.cc:7:25: error: expected primary-expression before ']' token
7 | d = new int [max];
| ^
a.cc:8:29: error: expected primary-expression before ';' token
8 | for(f1 = 0; f1 < max; f1++)
| ^
a.cc:8:29: error: expected ')' before ';' token
8 | for(f1 = 0; f1 < max; f1++)
| ~ ^
a.cc:8:35: error: expected ';' before ')' token
8 | for(f1 = 0; f1 < max; f1++)
| ^
| ;
a.cc:12:33: error: expected primary-expression before ';' token
12 | for(f1 = 2; f1 *f1 < max; f1++)
| ^
a.cc:12:33: error: expected ')' before ';' token
12 | for(f1 = 2; f1 *f1 < max; f1++)
| ~ ^
a.cc:12:39: error: expected ';' before ')' token
12 | for(f1 = 2; f1 *f1 < max; f1++)
| ^
| ;
|
s894284318
|
p00009
|
C++
|
#include<iostream>
#include<math.h>
main(){int i,j,n,p[1000000];std::cin>>n;for(i=2;i<=n;i++)p[i]=1;for(i=2;i<n;i++)if(p[i])for(j=2;i*j<=n;j++)p[i*j]=0;j=0;for(i=2;i<=n;i++)j+=p[i];std::cout<<j<<lend;}
|
a.cc:3:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
3 | main(){int i,j,n,p[1000000];std::cin>>n;for(i=2;i<=n;i++)p[i]=1;for(i=2;i<n;i++)if(p[i])for(j=2;i*j<=n;j++)p[i*j]=0;j=0;for(i=2;i<=n;i++)j+=p[i];std::cout<<j<<lend;}
| ^~~~
a.cc: In function 'int main()':
a.cc:3:160: error: 'lend' was not declared in this scope
3 | main(){int i,j,n,p[1000000];std::cin>>n;for(i=2;i<=n;i++)p[i]=1;for(i=2;i<n;i++)if(p[i])for(j=2;i*j<=n;j++)p[i*j]=0;j=0;for(i=2;i<=n;i++)j+=p[i];std::cout<<j<<lend;}
| ^~~~
|
s193555443
|
p00009
|
C++
|
main(){int i,j,n;char p[1000000];while(scanf("%d",&n)!=-1){for(i=2;i<=n;i++)p[i]=1;for(i=2;i<n;i++)for(j=2;i*j<=n;j++)p[i*j]=0;j=0;for(i=2;i<=n;i++)j+=p[i];printf("%d\n",j);}}
|
a.cc:1:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
1 | main(){int i,j,n;char p[1000000];while(scanf("%d",&n)!=-1){for(i=2;i<=n;i++)p[i]=1;for(i=2;i<n;i++)for(j=2;i*j<=n;j++)p[i*j]=0;j=0;for(i=2;i<=n;i++)j+=p[i];printf("%d\n",j);}}
| ^~~~
a.cc: In function 'int main()':
a.cc:1:40: error: 'scanf' was not declared in this scope
1 | main(){int i,j,n;char p[1000000];while(scanf("%d",&n)!=-1){for(i=2;i<=n;i++)p[i]=1;for(i=2;i<n;i++)for(j=2;i*j<=n;j++)p[i*j]=0;j=0;for(i=2;i<=n;i++)j+=p[i];printf("%d\n",j);}}
| ^~~~~
a.cc:1:157: error: 'printf' was not declared in this scope
1 | main(){int i,j,n;char p[1000000];while(scanf("%d",&n)!=-1){for(i=2;i<=n;i++)p[i]=1;for(i=2;i<n;i++)for(j=2;i*j<=n;j++)p[i*j]=0;j=0;for(i=2;i<=n;i++)j+=p[i];printf("%d\n",j);}}
| ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
+++ |+#include <cstdio>
1 | main(){int i,j,n;char p[1000000];while(scanf("%d",&n)!=-1){for(i=2;i<=n;i++)p[i]=1;for(i=2;i<n;i++)for(j=2;i*j<=n;j++)p[i*j]=0;j=0;for(i=2;i<=n;i++)j+=p[i];printf("%d\n",j);}}
|
s179712498
|
p00009
|
C++
|
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
_Bool *list;
int n,i,j,cnt;
while(scanf("%d",&n) != EOF)
{
cnt = 0;
list = (int*)calloc(n+1,sizeof(int));
for(i = 2; i <= n; i++)
{
if(list[i] != 1) /*prime number:0 no prime numbers:1*/
{
cnt++;
for(j = i+i; j <= n; j+=i) list[j] = 1;
}
}
printf("%d\n",cnt);
free(list);
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:6:2: error: '_Bool' was not declared in this scope
6 | _Bool *list;
| ^~~~~
a.cc:6:9: error: 'list' was not declared in this scope
6 | _Bool *list;
| ^~~~
|
s960346456
|
p00009
|
C++
|
#include <iostream>
#include <cmath>
using namespace std;
#define N 1000000
int main()
{
bool prm[N];
for(int i=0; i<N; i++)
{
prm[i]=true;
}
int upto= (int) sqrt(N);
for(int i=2;i<= upto; i++)
{
if(prm[i])
for(int j=2; j*i<N; j++)
{
prm[i*j]=false;
}
}
int n;
while(cin>>n)
{
int count=0;
for(int i=2; i<=n; i++)
{
if(prm[i])
count++;
}
cout<<count<<endl;
}
}
return 0;
}
|
a.cc:34:9: error: expected unqualified-id before 'return'
34 | return 0;
| ^~~~~~
a.cc:35:1: error: expected declaration before '}' token
35 | }
| ^
|
s721126633
|
p00009
|
C++
|
#include <iostream>
#include <cmath>
using namespace std;
#define N 1000000
int main()
{
bool prm[N];
for(int i=0; i<N; i++)
{
prm[i]=true;
}
int upto= (int) sqrt(N);
for(int i=2;i<= upto; i++)
{
if(prm[i])
{
for(int j=2; j*i<N; j++)
{
prm[i*j]=false;
}
}
}
int n;
while(cin>>n)
{
int count=0;
for(int i=2; i<=n; i++)
{
if(prm[i])
count++;
}
cout<<count<<endl;
}
}
return 0;
}
|
a.cc:36:9: error: expected unqualified-id before 'return'
36 | return 0;
| ^~~~~~
a.cc:37:1: error: expected declaration before '}' token
37 | }
| ^
|
s603460376
|
p00009
|
C++
|
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
int main(void){
int n;
while(cin >> n){
if(n < 3){
if(n < 2){
cout << 0 << endl;
}else{
cout << 1 << endl;
}
}
for(int i = 3; i <= n; i += 2){
bool flag = true;
for(int j = 3; j <= sqrt(i); j += 2){
if(i % j == 0){
flag = false;
}
}
if(flag)
ans++;
}
cout << ans << endl;
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:24:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
24 | ans++;
| ^~~
| abs
a.cc:26:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
26 | cout << ans << endl;
| ^~~
| abs
|
s034640147
|
p00009
|
C++
|
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
int main(void){
int n;
bool p[1000000];
p[0] = p[1] = 0;
p[2] = 1;
int ans = 0;
bool flag;
for(int i = 0; i < 1000000; i++)
p[i] = false;
p[2] = true;
for(int i = 3; i <= 1000000; i += 2){
flag = true;
for(int j = 3; j * j <= i; j += 2){
if(i % j == 0){
flag = false;
break;
}
}
if(flag)
p[i] = true;
}
// cout << "end" << endl;
while(cin >> n){
int ans = 0;
for(int i = 2; i < n; i++){
if(p[i])
ans++;
}
cout << ansi << endl;
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:34:13: error: 'ansi' was not declared in this scope; did you mean 'ans'?
34 | cout << ansi << endl;
| ^~~~
| ans
|
s112202787
|
p00009
|
C++
|
#include <iostream>
#include <string>
using namespace std;
int main(){
int n;
cin >> n;
int a[n+1];
int b;
int c;
b=1;
while(b<n+1){
a[b]=0;
b=b+1;}
a[1]=1;
b=2;
while(b<n+1){
if(a[b]=0){ c=2; while(1){if(c*b>n){break;} a[c*b]=1; c=c+1;}
b=b+1;}
int d;
d=0;
b=1;
while(b<n+1){
if(a[b]=0){d=d+1;}
b=b+1;}
cout << d;
}
|
a.cc: In function 'int main()':
a.cc:30:2: error: expected '}' at end of input
30 | }
| ^
a.cc:5:11: note: to match this '{'
5 | int main(){
| ^
|
s751946095
|
p00009
|
C++
|
int main(){
int n;
while(cin >> n){
int a[n+1];
int b;
int c;
b=1;
while(b<n+1){
a[b]=0;
b=b+1;}
a[1]=1;
int d;
d=0;
b=2;
while(b<n+1){
if(a[b]==0){d=d+1; c=2; while(1){if(c*b>n){break;} a[c*b]=1; c=c+1;}}
b=b+1;}
cout << d;}
|
a.cc: In function 'int main()':
a.cc:3:7: error: 'cin' was not declared in this scope
3 | while(cin >> n){
| ^~~
a.cc:18:1: error: 'cout' was not declared in this scope
18 | cout << d;}
| ^~~~
a.cc:18:12: error: expected '}' at end of input
18 | cout << d;}
| ^
a.cc:1:11: note: to match this '{'
1 | int main(){
| ^
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.