51 lines
1.0 KiB
C++
51 lines
1.0 KiB
C++
//youwu
|
|
#include <cmath>
|
|
#include <iostream>
|
|
using namespace std;
|
|
bool pan(int n)
|
|
{
|
|
if (n < 2) {
|
|
return 0;
|
|
}
|
|
if (n == 2) {
|
|
return 1;
|
|
}
|
|
int len = sqrt(n);
|
|
for (int i = 2; i <= len; i++) {
|
|
if (n % i == 0) {
|
|
return 0;
|
|
}
|
|
}
|
|
return 1;
|
|
}
|
|
int main()
|
|
{
|
|
int n, f[100001] = { 0 }, now = 1, next = 2;
|
|
bool ans[1000001] = { 0 };
|
|
cin >> n;
|
|
|
|
int tou = 0, wei = 1;
|
|
do {
|
|
tou++;
|
|
if (tou == next) {
|
|
next = wei + 1;
|
|
now *= 10;
|
|
}
|
|
for (int i = 0; i < 10; i++) {
|
|
int zhe = i * now + f[tou];
|
|
if (zhe > n) {
|
|
for (int i = 10; i <= n; i++) {
|
|
if (ans[i] == 1) {
|
|
cout << i << endl;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
if (pan(zhe) == 1) {
|
|
f[++wei] = zhe;
|
|
ans[zhe] = 1;
|
|
}
|
|
}
|
|
} while (tou < wei);
|
|
}
|