劳烦大佬帮忙看看哪里错了

P1217 [USACO1.5] 回文质数 Prime Palindromes

_Nelly @ 2022-11-11 00:40:30


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

bool HuiWen(int n) {
    int y = n;
    int reverse = 0;
    while (y > 0) {
        reverse = reverse * 10 + y % 10;
        y /= 10;
    }
    if (reverse == n)
        return 1;
    else
        return 0;
}

int book[100000001] = {1, 1};
int  prime[100000001]=;
int cnt;

void Euler() {
    for (int i = 2; i < 100000001; i++) {
        if (!book[i]) {
            prime[++cnt] = i;
        }
        for (int j = 1; j <= cnt && prime[j]*i < 100000001; j++) {
            book[prime[j]*i] = 1;
            if (i % prime[j] == 0)
                break;
        }

    }
}

int main() {
    int a, b;
    cin >> a >> b;
    Euler();
    for (int i = a; i <= b; i++) {
        if (HuiWen(i) && !book[i]) {

            cout << i << endl; ;

        }
    }

    return 0;
}

```自己在Dev-c++上编译通过了
但是洛谷上显示CE是为什么?
g++: 编译器内部错误:File size limit exceeded signal terminated program as

by zhizhi_c @ 2022-11-11 14:24:05

@_Nelly 第几行CE了


by _Nelly @ 2022-11-11 21:44:13

@zhizhi_c 我发现全局变量定义的数组太大时 写int book[100000001]={1,1};

洛谷IDE会报错。但是先不管到它,到主函数里才写book[1]=1 就不报错.

这是为啥?


by zhizhi_c @ 2022-11-12 10:05:13

@_Nelly 可能是二维数组定义出错 改int book[100000001]={{1,1}};


|