- tuxingzhe2024's blog
任何一个十进制中含有数字7的数,它的所有倍数都不能报出来
- 2025-1-10 22:59:41 @
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=1e6+15;
const int mod=1e9+7;
int T,x=1,t;
int f[maxn],a[maxn];
inline bool q(int x) {
while(x) {
if(x%10==7) return 1;
x/=10;
}
return 0;
}
inline void DRG() {
for(int i=1;i<=1e6+5;i++) {
if(f[i]) continue;
if(q(i)) {
for(int j=i;j<=1e6+5;j+=i) f[j]=1;
continue;
}
a[t]=i;
t=i;
}
}
signed main() {
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
DRG();
cin>>T;
while(T--) {
cout<<x<<"\n";
x=a[x];
}
return 0;
}