Facebook
From Nguyễn Tiến Anh, 1 Month ago, written in C++.
Embed
Download Paste or View Raw
Hits: 145
  1. #include <bits/stdc++.h>
  2. typedef long long ll;
  3. #define FOR(i,l,r) for (int i=l;i<=r;i++)
  4. #define FOD(i,r,l) for (int i=r;i>=l;i--)
  5. #define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  6.  
  7. using namespace std;
  8. const int N = 1e6+5;
  9. bool Pr[N+1];
  10. void sang() {
  11.     for(int i = 0; i <= N;++i) {
  12.         Pr[i] = true;
  13.     }
  14.     Pr[0] = false;
  15.     Pr[1] = false;
  16.     for(int i = 2; i * i <= N; ++i) {
  17.          if(Pr[i] == true) {
  18.              for(int j = i * i; j <= N; j += i)
  19.                  Pr[j] = false;
  20.         }
  21.     }
  22. }
  23. int main()
  24. {
  25.     freopen("beaunum.inp","r",stdin);
  26.     freopen("beaunum.out","w",stdout);
  27.     fast;
  28.     sang();
  29.     long long n,cnt=0; cin>>n;
  30.     n = sqrt(sqrt(n));
  31.     for(int i=1;i<=n;i++)
  32.     {
  33.         if (Pr[i]) cnt++;
  34.     }
  35.     cout<<cnt;
  36. }
  37.  
  38.  

Replies to beaunum rss

Title Name Language When
countnum Nguyễn Tiến Anh cpp 1 Month ago.