Advertisement
Guest User

Untitled

a guest
Jan 27th, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define int long long
  4.  
  5. bool check(int n){
  6. int dn=0;
  7. int n1=n;
  8. while (n1 != 0){
  9. ++dn;
  10. n1 /= 10;
  11. }
  12. int res=(dn+1)/2;
  13. while (n != 0){
  14. if (n%10 == n/(int)(pow(10, dn-1))){
  15. n%=(int)(pow(10, dn-1));
  16. n/=10;
  17. dn-=2;
  18. }
  19. else{
  20. return false;
  21. }
  22. }
  23. return true;
  24. }
  25.  
  26. signed main(){
  27. int a, n;
  28. cin >> a >> n;
  29.  
  30. vector<bool> v(n+1, true);
  31. v[0] = false;
  32. v[1] = false;
  33.  
  34. for (int i=2; i<=n; ++i){
  35. if (v[i]){
  36. for (int j=i*i; j<=n; j+=i){
  37. v[j] = false;
  38. }
  39. }
  40. }
  41. int c = 0;
  42. for (int i=a; i<=n; ++i){
  43. if (v[i]) {
  44. if (check(i)){
  45. cout << i << " ";
  46. ++c;
  47. }
  48. }
  49. }
  50. if (!c) cout << c;
  51. return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement