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

Replies to beaunum rss

Title Name Language When
Re: beaunum Phạm Tấn Dũng cpp 1 Month ago.