Saleh127

eolymp 4739

Sep 17th, 2020
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. #define maX 1000008
  6. vector<ll>xx;
  7. bool marked[maX];
  8. void sieve()
  9. {
  10. marked[0]=1;
  11. marked[1]=1;
  12. for(ll i=4; i<=maX; i+=2)
  13. {
  14. marked[i]=1;
  15. }
  16. for(ll i=3; i<=maX; i+=2)
  17. {
  18. if(marked[i]==0)
  19. {
  20.  
  21. for(ll j=i*i; j<=maX; j+=i+i)
  22. {
  23. marked[j]=1;
  24. }
  25. }
  26. }
  27. }
  28. int main()
  29. {
  30. ios_base::sync_with_stdio(0);
  31. cin.tie(0);
  32. cout.tie(0);
  33.  
  34. sieve();
  35. ll a,c,d,e,i,j;
  36. cin>>a>>c;
  37. for(i=a;i<=c;i++)
  38. {
  39. if(marked[i]==0)
  40. {
  41. cout<<i<<" ";
  42. }
  43. }
  44. cout<<endl;
  45.  
  46. return 0;
  47. }
  48.  
Advertisement
Add Comment
Please, Sign In to add comment