Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
619 B
2
Indexable
Never
#include <bits/stdc++.h>
using namespace std;
bool isp(int x) {
    if (x == 1) return false;
    for (int i = 2; i * i <= x; i++) {
        if (x % i == 0) return false;
    }
    return true;
}
bool huiwen(int x) {
    string s = to_string(x);
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != s[s.size() - 1 - i]) return false;
    }
    return true;
}
int main() {
    freopen("count.in", "r", stdin);
    freopen("count.out", "w", stdout);
    int l, r, cnt = 0;
    cin >> l >> r;
    for (int i = l; i <= r; i++) {
        if (isp(i) && huiwen(i)) cnt++;
    }
    cout << cnt << endl;
    return 0;
}