fork download
  1. #include<iostream>
  2. using namespace std;
  3. #define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
  4. #define open(name) freopen(name".INP","r",stdin);freopen(name".OUT","w",stdout)
  5. #define FOR(i,a,b) for(int i=a;i<=b;i++)
  6. #define mkcode() int main()
  7. const int N=1e7+5;
  8. int n;
  9. bool cnt[N];
  10. void uoc(int n){
  11. FOR(i,2,n) cnt[i]=true;
  12. for(int i=2;i*i<=n;i++){
  13. if(cnt[i]){
  14. for(int j=i*i;j<=n;j+=i) cnt[j]=false;
  15. }
  16. }
  17. }
  18. mkcode(){
  19. fast();
  20. open("tcsc");
  21. cin>>n;
  22. uoc(n);
  23. FOR(i,1,n){
  24. if(cnt[i]) cout<<i<<" ";
  25. }
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
Standard output is empty