fork download
  1. /**
  2.  * author: orzvanh14 ( Độc cô cầu đặc )
  3.  * created: 23.12.2022 10:08:02
  4.  * too lazy to update time
  5. **/
  6. // i wants to take ioi
  7. //binhtinhtutinkhongcaycunhungmotkhikhongcontutinnualatuyetvong
  8. #include <bits/stdc++.h>
  9.  
  10. using namespace std;
  11.  
  12. #define int long long
  13. #define nn "\n"
  14. #define pi pair<int, int>
  15. #define fi first
  16. #define se second
  17. #define lb lower_bound
  18. #define ub upper_bound
  19. #define eb emplace_back
  20. #define pb push_back
  21. #define TASK " "
  22.  
  23. #define ms(a, x) memset(a, x, sizeof(a))
  24. #define all(a) a.begin(), a.end()
  25. #define All(a, n) a + 1, a + 1 + n
  26.  
  27. #define LOG 19
  28.  
  29.  
  30. const int INF = 1e18;
  31. const int mod = 1e9+7;
  32. const int N = 1e7 + 5;
  33. const int maxn = 1e3 + 5;
  34. int MOD = 998244353;
  35. int bit[200000];
  36. struct node{
  37. int kc, u, hk;
  38. bool operator<(const node& other) const {
  39. return kc > other.kc;
  40. }
  41. };
  42. struct edge{
  43. int v, w, h;
  44. };
  45. int l, r;
  46. bool p[N];
  47. vector<int> primes;
  48. vector<int> v;
  49. void nhap(){
  50. cin >> l >> r;
  51. }
  52. void sang(){
  53. p[1] = 1;
  54. for(int i = 2; i * i < N; i++){
  55. if(!p[i]){
  56. for(int j = i * i; j < N; j += i){
  57. p[j] = 1;
  58. }
  59. }
  60. }
  61. for(int i = 2; i < N; i++){
  62. if(!p[i]) primes.pb(i);
  63. }
  64. }
  65. bool sum(int n){
  66. int s = 0;
  67. while(n != 0){
  68. int d = n % 10;
  69. n /= 10;
  70. s += d;
  71. }
  72. if(!p[s]) return true;
  73. return false;
  74. }
  75. void solve(){
  76. sang();
  77. for(int k : primes){
  78. if(sum(k)){
  79. v.pb(k);
  80. }
  81. }
  82. auto it = lb(all(v), l) - v.begin();
  83. auto it1 = ub(all(v), r) - v.begin();
  84. it1;
  85. for(int i = it; i < it1; i++){
  86. cout << v[i] << " ";
  87. }
  88. }
  89. // 0 0 0 0 0 0 0
  90. signed main() {
  91. // freopen("WORK.INP", "r", stdin);
  92. // freopen("WORK.OUT", "w", stdout);
  93. ios_base::sync_with_stdio(0);
  94. cin.tie(0);
  95. cout.tie(0);
  96. nhap();
  97. solve();
  98. return 0;
  99.  
  100. }
  101. // https://i...content-available-to-author-only...e.com/7poJyz
  102. // https://i...content-available-to-author-only...e.com/pScgCp
Success #stdin #stdout 0.08s 23532KB
stdin
Standard input is empty
stdout
Standard output is empty