#include<cstdio>
bool flag[77777778];
int last,next[77777778];
inline bool check(int checker){
while(checker){
if(checker%10==7){
return true;
};
checker/=10;
};
return false;
};
inline void sift(void){
for(int first=0;first<=10000000;++first){
if(flag[first]){
continue;
};
if(check(first)){
flag[first]=true;
for(int second=first;second<=10000000;second+=first){
flag[second]=true;
};
continue;
};
next[last]=first;
last=first;
};
return;
};
int main(int argc,char **argv){
int test;
scanf("%d",&test);
sift();
while(test--){
int ask;
scanf("%d",&ask);
if(flag[ask]){
puts("-1");
}else{
printf("%d\n",next[ask]);
};
};
return 0;
};
看了别的讨论,发现可能开小了,从 1e7 到了 7777778,但是为什么还是 WA 了后仨点?