#include <iostream> #include <string> #include <cmath> #include <vector> using namespace std; bool isS(int n);//判断素数 bool isP(int n);//判断回文 int main() { vector<int>res; int a, b; cin >> a >> b; for (int i = a; i <= b; i++) { if (isS(i) && isP(i)) res.push_back(i); } int l = res.size(); for (int i = 0; i < l-1; i++) { cout << res[i] << " "; } cout << res[l-1]; return 0; } bool isS(int n) { int l = (int)sqrt(n); for (int i = 2; i <= l; i++) { if (n % i == 0) return false; } return true; } bool isP(int n) { //if n == reverseN return true; int reverseN = 0; int tmp = n; while (tmp > 0) { reverseN = reverseN * 10 + (tmp % 10); tmp /= 10; } //cout << reverseN << " "; return n == reverseN; }