来人解释一下T1为什么RE?
  • 板块学术版
  • 楼主王烨
  • 当前回复3
  • 已保存回复3
  • 发布时间2021/11/20 21:02
  • 上次更新2023/11/3 23:55:26
查看原帖
来人解释一下T1为什么RE?
207671
王烨楼主2021/11/20 21:02
#include<bits/stdc++.h>
using namespace std;
const int N=10000010;
int t,ne[N];
bool noo[N];
bool check(int x){
	while(x){
		if(x%10==7) return true;
		x/=10;
	}
	return false;
}
int main(){
	//freopen("number.in","r",stdin);
	//freopen("number.out","w",stdout);
	scanf("%d",&t);
	for(int i=1;i<=N;i++){
		if(noo[i]) continue;    
		if(check(i)){
			noo[i]=1;
			int upp=N/i;
			for(int j=2;j<=upp;j++)
				if(!noo[j]) noo[j*i]=1;
		}
		else
			for(int j=i-1;j>=1;j--)
				if(!noo[j]){
					ne[j]=i;
					break;
				}
	}
	while(t--){
		int x;
		scanf("%d",&x);
		if(noo[x]) puts("-1");
		else printf("%d\n",ne[x]);
	}
	return 0;
}
2021/11/20 21:02
加载中...