Advertisement
Singasking

https://www.spoj.com/submit/TDPRIMES/id=30737509

Jan 20th, 2023
1,021
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.     const int n=1e8;
  4.     vector<int> lp(n+1,true);
  5.     vector<int> primes;
  6.  
  7. int main() {
  8.    
  9.     // your code here
  10.  
  11. //  for(int i=0;i<=n;i++ ) lp[i]=i;
  12. for(int i=2;i<=sqrt(n);i++ ){
  13.     if(lp[i]==true) {
  14.         for(int j=i*i;j<=n;j+=i) {
  15.             lp[j]=false;
  16.         }
  17.         primes.push_back(i);
  18.     }
  19. }
  20. for(int i=1;i<=primes.size();i+=100) {
  21.     cout<<primes[i-1]<<endl;
  22. }
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement