Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define int long long
- bool check(int n){
- int dn=0;
- int n1=n;
- while (n1 != 0){
- ++dn;
- n1 /= 10;
- }
- int res=(dn+1)/2;
- while (n != 0){
- if (n%10 == n/(int)(pow(10, dn-1))){
- n%=(int)(pow(10, dn-1));
- n/=10;
- dn-=2;
- }
- else{
- return false;
- }
- }
- return true;
- }
- signed main(){
- int a, n;
- cin >> a >> n;
- vector<bool> v(n+1, true);
- v[0] = false;
- v[1] = false;
- for (int i=2; i<=n; ++i){
- if (v[i]){
- for (int j=i*i; j<=n; j+=i){
- v[j] = false;
- }
- }
- }
- int c = 0;
- for (int i=a; i<=n; ++i){
- if (v[i]) {
- if (check(i)){
- cout << i << " ";
- ++c;
- }
- }
- }
- if (!c) cout << c;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement