fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define endl '\n'
  4. #define int long long
  5. const int MOD = pow(10,9)+7;
  6. const int MOD2 = 998244353;
  7. const int INF = LLONG_MAX/2;
  8.  
  9. int primes[1000000];
  10.  
  11. void seive(){
  12. fill(primes, primes + 1000000, 1);
  13. primes[0] = primes[1] = 0;
  14. for(int i = 2 ; i*i < 1000000 ; i++){
  15. if(primes[i]){
  16. for(int j = i*i ; j < 1000000 ; j += i){
  17. primes[j] = 0;
  18. }
  19. }
  20. }
  21. }
  22. void solve() {
  23. seive();
  24. for(int i = 0 ; i<=100; i++){
  25. if(primes[i]==1){
  26. cout<<i<<" ";
  27. }
  28. }
  29. cout<<endl;
  30. }
  31.  
  32. signed main(){
  33. ios::sync_with_stdio(false); cin.tie(NULL);
  34. //int t;
  35. //cin >> t;
  36. //while(t--){
  37. solve();
  38. //}
  39. return 0;
  40. }
Success #stdin #stdout 0.01s 11376KB
stdin
Standard input is empty
stdout
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97