Advertisement
aayyk

Untitled

Sep 15th, 2020
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.66 KB | None | 0 0
  1. //#pragma GCC optimize("Ofast")
  2.  
  3. #ifdef LOCAL
  4. #include "debug.h"
  5. #else
  6. #include <bits/stdc++.h>
  7. #define debug(x...)
  8. #endif
  9.  
  10. #define int ll
  11.  
  12. using namespace std;
  13. typedef long long ll;
  14. typedef long double ld;
  15. typedef pair <int, int> pii;
  16. #define sz(x) int((x).size())
  17.  
  18. #ifdef ONLINE_JUDGE
  19. mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  20. #else
  21. mt19937 rng(1000 - 7);
  22. #endif
  23.  
  24. const int N = 4e4 + 7;
  25. const int M = 10;
  26. const int MOD2 = 998244353;
  27. const int MOD = 1e9 + 7;
  28. const ld eps = 1e-6;
  29. const pii dir[] = { { 0, 1 }, { 0, -1 }, { 1, 0 }, { -1, 0 } };
  30.  
  31.  
  32.  
  33. signed main() {
  34. #ifdef LOCAL
  35.     freopen("input.txt", "r", stdin);
  36.     freopen("output.txt", "w", stdout);
  37. #endif
  38.     cout << fixed << setprecision(9);
  39.     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  40.  
  41.     const int n = 10000;
  42.     const int c = 100;
  43.     vector <int> primes, p(c + 1);
  44.  
  45.     for (int i = 2; i < c; i++) {
  46.         if (!p[i]) {
  47.             for (int j = i * i; j < c; j += i) {
  48.                 p[j] = 1;
  49.             }
  50.             primes.push_back(i);
  51.         }
  52.     }
  53.  
  54.     for (int i = c; i <= n; i += c) {
  55.         fill(p.begin(), p.end(), 0);
  56.         for (int x : primes) {
  57.             if (x * x >= i + c) {
  58.                 break;
  59.             }
  60.             int y = ((i + x - 1) / x) * x;
  61.             for (int j = y; j < min(n + 1, i + c); j += x) {
  62.                 p[j % c] = 1;
  63.             }
  64.         }
  65.         for (int j = 0; j < c; j++) {
  66.             if (!p[j] && i + j <= n) {
  67.                 primes.push_back(i + j);
  68.             }
  69.         }
  70.     }
  71.  
  72.     for (int x : primes) {
  73.         cout << x << endl;
  74.     }
  75.  
  76.     return 0;
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement