自测全部正确,洛谷爆零
查看原帖
自测全部正确,洛谷爆零
233347
cocoxu楼主2021/11/22 16:40

自测全部正确,洛谷爆零

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int INF1 = 2e7 + 1000;
int t;
int p[INF1];
void get_p() {
	for (int k = 7; k <= INF1; k++) {
		if (p[k]) {
			continue;
		}
		int f = 0, x = k;
		while (x) {
			if (x % 10 == 7) {
				f = 1;
				p[k] = 1;
				break;
			}
			x /= 10;
		}
		if (f) {
			for (int i = 2; i * k <= INF1; i++) {
				p[i * k] = 1;
			}
		}
	}
}

int main() {
	cin >> t;
	memset(p, 0, sizeof(p));
	get_p();
    
	for (int i = 0; i < t; i++) {
		int x;
		cin >> x;
		if (p[x]) {
			cout << -1 << endl;
		} else {
			int j = x + 1;
			while(1) {
				if (p[j] == 1) {
					j++;
					continue;
				} else {
					cout << j << endl;
					break;
				}
			}
		}
	}
	return 0;
}

数据自测

200000大数据全部正确,洛谷和其他平台爆零 orz

全部WA,line 2 too short

2021/11/22 16:40
加载中...