Advertisement
Ahmed_Negm

Untitled

Jul 11th, 2022
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.66 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define ll long long
  5. #define ull unsigned long long
  6. #define nl '\n'
  7. #define sz(x) int(x.size())
  8. #define all(x) x.begin(),x.end()
  9. #define rall(s)  s.rbegin(), s.rend()
  10. #define getline(s) getline(cin>>ws,s)
  11. #define ceill(n, m) (((n) / (m)) + ((n) % (m) ? 1 : 0))
  12. #define pi  3.141592653589793
  13.  
  14. /*
  15. ███╗░░██╗███████╗░██████╗░███╗░░░███╗
  16. ████╗░██║██╔════╝██╔════╝░████╗░████║
  17. ██╔██╗██║█████╗░░██║░░██╗░██╔████╔██║
  18. ██║╚████║██╔══╝░░██║░░╚██╗██║╚██╔╝██║
  19. ██║░╚███║███████╗╚██████╔╝██║░╚═╝░██║
  20. ╚═╝░░╚══╝╚══════╝░╚═════╝░╚═╝░░░░░╚═╝
  21.  
  22. */
  23.  
  24. void Fast_IO(){
  25. ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  26. // freopen("filename.in", "r", stdin);
  27. #ifndef ONLINE_JUDGE
  28. freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  29. #endif
  30. }
  31.  
  32.  
  33. vector<ll>prime(5000);
  34. void sieve(){
  35.     for(int i=2; i<=3000; i++){
  36.         if(!prime[i]){
  37.             for(int j = 2*i; j<=3000; j+=i) prime[j]++;
  38.         }
  39.     }
  40. }
  41.  
  42.  
  43. void solve(){
  44.     sieve();
  45.     ll n,res =0; cin>>n;
  46.  
  47.     for(int i=2; i<=n; i++){
  48.         if(prime[i]==2) res++;
  49.     }
  50.     cout<<res<<nl;
  51.  
  52.  
  53.  
  54. }
  55.  
  56. int main(){
  57.     Fast_IO();
  58. int t =1;
  59. //cin>>t;
  60. while(t--){
  61. solve();
  62. }
  63. return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement