#include <bits/stdc++.h>
using namespace std;
bool ish(int x) {
vector<int> s;
while (x > 0) {
s.push_back(x % 10);
x /= 10;
}
for (int j = s.size() - 1, i = 0; j >= 0 && i < s.size(); j--, i++)
if (s[i] != s[j])
return false;
return true;
}
bool isz(int x) {
for (int i = 3; i <= sqrt(x); i += 2)
if (x % i == 0)
return false;
return true;
}
int main() {
ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
int a, b;
cin >> a >> b;
if (a > b)
swap(a, b);
if (a == 2)
cout << a << endl;
if (a % 2 == 0)
a++;
for (int i = a; i <= b; i += 2) {
if (ish(i) && isz(i))
cout << i << endl;
}
return 0;
}
呜呜呜,已经尽量优化了,1200ms,超得好多