P
r
o
b
l
e
m
l
i
n
k
Problem~link
Problem link
分析:
筛子
当前数
x
x
x如果被标记 就跳过 看
x
x
x是否含有
7
7
7 如果有就把
x
x
x的倍数都标记
记录下下一个报的数即可
CODE:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=1e7+5;
int T,f[N],ans[N],tot;
bool check(int x)
{
while(x)
{
if(x%10==7) return 1;
x/=10;
}
return 0;
}
void work()
{
for(int i=1;i<N;i++)
{
if(f[i]) continue;
if(check(i))
{
for(int j=i;j<N;j+=i) f[j]=1;
continue;
}
ans[tot]=i;
tot=i;
}
}
int main()
{
work();
scanf("%d",&T);
while(T--)
{
int x;
scanf("%d",&x);
if(f[x]) puts("-1");
else printf("%d\n",ans[x]);
}
return 0;
}