'commit'
This commit is contained in:
33
TangDou/LuoGuBook/P1217_1.cpp
Normal file
33
TangDou/LuoGuBook/P1217_1.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include<bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
const int N = 1e8 + 10;
|
||||
int primes[N], cnt;
|
||||
bool st[N];
|
||||
void get_primes(int n) {
|
||||
for (int i = 2; i <= n; i++) {
|
||||
if (!st[i]) primes[cnt++] = i;
|
||||
for (int j = 0; primes[j] <= n / i; j++) {
|
||||
st[primes[j] * i] = true;
|
||||
if (i % primes[j] == 0) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool isHWS(int num) {
|
||||
int t = num, ans = 0;
|
||||
while (t) {
|
||||
ans = ans * 10 + t % 10;
|
||||
t /= 10;
|
||||
}
|
||||
return ans == num;
|
||||
}
|
||||
int main() {
|
||||
int a, b;
|
||||
cin >> a >> b;
|
||||
if (b >= 1e7) b = 1e7;
|
||||
get_primes(b);
|
||||
for (int i = a; i <= b; i++)
|
||||
if (!st[i] && isHWS(i))
|
||||
cout << i << endl;
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user