Untitled
unknown
plain_text
4 years ago
619 B
4
Indexable
#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; }
Editor is loading...