HELP!Help!help!

P3383 【模板】线性筛素数

bz029 @ 2024-07-29 10:16:04

用下面的代码提交CE了

Compile Error

显示

g++: 编译器内部错误:File size limit exceeded signal terminated program as Please submit a full bug report, with preprocessed source (by using -freport-bug). 参阅 https://gcc.gnu.org/bugs/ 以获取指示。

这里

#include <bits/stdc++.h>
using namespace std;

int n,i,j,x;
bool a[100000005]={1,1};
int b[100000005];
int q,k;

int main(){
    scanf("%d%d",&n,&q);
    for(i=2;i<=n;i++){
        if(a[i]==0){
            b[++k]=i;
        }
        for(j=1;j<=k;j++){
            if(i*b[j]>n){
                break;
            }
            a[i*b[j]]=1;
            if(i%b[j]==0){
                break;
            }
        }
    }
    for(int i=1;i<=q;i++){
        scanf("%d",&x);
        printf("%d\n",b[x]);
    }

    return 0;
}

by yukimianyan @ 2024-07-29 10:17:20

bool a[100000005]={1,1}; -> bool a[100000005]; a[0] = a[1] = 1;后面那句写在函数体里面


by bz029 @ 2024-07-29 10:22:43

@yukimianyan

AC了,谢谢;


|