Facebook
From trần bá nguyên, 1 Month ago, written in Plain Text.
This paste is a reply to coutnum from trần bá nguyên - view diff
Embed
Download Paste or View Raw
Hits: 147
  1. #include<bits/stdc++.h>
  2. #define FOR(x,a,b) for (int x=a;x<=b;x++)
  3. #define FOD(x,a,b) for (int x=a;x>=b;x--)
  4. #define pub push_back
  5. #define pob pop_back
  6. #define ii  pair<int,int>
  7. #define pll pair<long long, long long>
  8. #define F first
  9. #define S second
  10. #define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
  11. typedef unsigned long long int ull;
  12. typedef long long ll;
  13. const long N=1e6 + 5;
  14. const int mod = 1e9 +7;
  15. using namespace std;
  16. ll n,res=0;
  17. bool kt[N+1];
  18. void them(){
  19.     FOR(i,0,N) {
  20.         kt[i] = true;
  21.     }
  22.     kt[0] = false;
  23.     kt[1] = false;
  24.     for(int i = 2; i * i <= N; ++i) {
  25.          if(kt[i] == true) {
  26.              for(int j = i * i; j <= N; j += i)
  27.                  kt[j] = false;
  28.         }
  29.     }
  30. }
  31. void solve(){
  32.     them();
  33.     cin >> n;
  34.     n=sqrt(sqrt(n));
  35.     for(int i=1;i<=n;i++)
  36.     {
  37.         if (kt[i]) res++;
  38.     }
  39.     cout << res;
  40. }
  41. int main(){
  42.     fast;
  43.      freopen("beaunum.inp","r",stdin);
  44.      freopen("beaunum.out","w",stdout);
  45.     solve();
  46.     return 0;
  47. }
  48.