C++14过不了,17和20能过,求助!!
查看原帖
C++14过不了,17和20能过,求助!!
801312
fazeup楼主2023/11/27 21:03

很神奇,14会全re


#include<iostream>
using namespace std;

const int maxn=1e7+5;
int num[maxn],vis[maxn],cnt=0;
bool check(int x){
	while(x){
		if(x%10==7) return false;
		x/=10;
	}
    return true;
}
void trial(){
	for(int i=1;i<=maxn;i++){
		if(vis[i]==0)
		{
			if(check(i))
			{
				vis[i]=++cnt;
				num[cnt]=i;
			}
			else{
				for(int j=1;i*j<maxn;j++){
					vis[i*j]=-1;
				}
			}
		}
	}
	
}

int main(){
//	ios::sync_with_stdio(false);
	int t,n;
    cin>>t;
    trial();
    while(t--){
	 	cin>>n;
	 	if(vis[n]==-1){
		 	cout<<-1<<endl;
		}
		else
		{
			cout<<num[vis[n]+1]<<endl;
		}
	}
//    for(int i=1;i<=10;i++){
//		cout<<vis[i]<<","<<num[i]<<endl;
//	}
    return 0;
}

2023/11/27 21:03
加载中...