70pts求调
查看原帖
70pts求调
893608
cx2021ghj楼主2024/10/15 18:13
#include<bits/stdc++.h>
using namespace std;
int n,x,last,nxt[10000009];
bool f[10000009];
bool pd(int x){
	int res=x;
	while(res){
		int s=res%10;
		if(s==7) return 1;
		res/=10;
	}
	return 0;
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(int i=1;i<=10000000;i++){
		if(f[i]) continue;
		if(pd(i)){
			for(int j=i;j<=10000000;j+=i)
				f[j]=1;
			continue;
		}	
		nxt[last]=i;
		last=i;
	}
	for(int i=1;i<=n;i++){
		cin>>x;
		if(f[x]){
			cout<<"-1"<<'\n';
			continue;
		}
		cout<<nxt[x]<<'\n';
	}
}

Wa了3个点。

2024/10/15 18:13
加载中...