Facebook
From Phạm Tấn Dũng, 1 Month ago, written in C++.
This paste is a reply to beaunum from Phạm Tấn Dũng - view diff
Embed
Download Paste or View Raw
Hits: 125
  1. #include<bits/stdc++.h>
  2. #define endl '\n'
  3. #define pb push_back
  4. #define int long long
  5. #define And << " " <<
  6. #define reset(a, x) memset(a, x, sizeof(a))
  7. #define End cout << '\n' << "\n"; return 0;
  8. #define FOR(i, l, r) for (int i = l; i <= r; i++)
  9. #define fast() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  10. using namespace std;
  11.  
  12. const int MAX = 5e4;
  13. const int N = 5e4 + 5;
  14.     bool s[N];
  15.  
  16. void sind()
  17. {
  18.     memset(s, true, sizeof(s));
  19.     s[1] = false;
  20.  
  21.     FOR(i,2,MAX)
  22.     {
  23.         if (!s[i]) continue;
  24.  
  25.         for(int j = i * i; j <= MAX; j += i)
  26.             s[j] = false;
  27.     }
  28. }
  29.  
  30. void solve()
  31. {
  32.     sind();
  33.  
  34.     int n; cin >> n;
  35.     n = sqrt(sqrt(n));
  36.  
  37.     int bien = 0;
  38.     for(int i = 1; i <= n; i++)
  39.         bien += s[i];
  40.  
  41.     cout << bien;
  42. }
  43.  
  44. int32_t main()
  45. {
  46.     fast();
  47.     freopen("beaunum", "r", stdin);
  48.     freopen("beaunum", "w", stdout);
  49.         solve();
  50.     End;
  51. }
  52. //100
  53.