求 总是re
查看原帖
求 总是re
419180
zhouguanxu楼主2021/12/17 11:48
#include<bits/stdc++.h>
using namespace std;

const int Max=2e7;

int ne[Max+30000];
bool st[Max+30000];

int T;
int temp;

bool havese(int num)
{
	while(num)
	{
		if(num%10==7)return 1;
		num/=10;
	}

	return 0;

}

int workout()

{

	int last = 0;

	int i=0;

	while(i<Max)

	{

		i++;
					if(i>Max)cout<<"i"<<i;
					 if(i<0)cout<<" i"<<i; 
		if(!st[i])

		{

			if(havese(i))

			{
	
				for(int j=i;j<Max+460;j+=i)
					{
					 if(j>Max+460)cout<<"j:"<<j;
					 if(j<0)cout<<"j:"<<j; 
					st[j]=1;	
						} 
			}

			else
			{
				ne[last]=i;
					if(last>Max+460)cout<<"last:"<<last;
					 if(last<0)cout<<"last:"<<last; 
				last=i;
			}
		}
	}
}


int main()

{

	workout();

	cin>>T;

	while(T--)

	{

		

		cin>>temp;

		if(st[temp])puts("-1");

		else printf("%d\n",ne[temp]);
		return 0;
	}

	return 0;

} 
2021/12/17 11:48
加载中...