崩溃了
查看原帖
崩溃了
1383564
DDV1楼主2024/8/7 14:15
#include<bits/stdc++.h>
using namespace std;
const int N=1e7+10;
int a[N];
int j1(int x){
	if(x%7==0)
	return 1;
	return 0; 
}
int j2(int x){
	int c=x;
	while(c){
		if(c%10==7)
		return 1;
		c/=10;
	}
	return 0;
}
int fun(int x){
	while(a[x+1]==-1)x++;
	return x+1;}
	int main(){
	
	for(int i=1;i<=N;i++){
		if(j1(i)==1 or j2(i)==1){
			a[i]==-1;
			for(int j=i;j+i<=N;j=j+i){
				a[j]=-1;
			}
		}
	}
	int T,x;
	cin>>T;
	for(int i=1;i<=T;i++){
		scanf("%d",x);
	if(a[x]==-1)
		cout<<-1<<"\n";
		printf("%d\n",fun(x));
	}
	return 0;
} 
2024/8/7 14:15
加载中...