fork download
  1. #include <iostream>
  2. #include <bits/stdc++.h>
  3. #define Kirlos ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
  4. #define ll long long
  5. #define pb(k) push_back(k)
  6. #define fi first
  7. #define se second
  8. #define endl '\n'
  9. #define mp(x,y) make_pair(x,y)
  10. #define MOD 1000000007
  11. #define all(x) x.begin(), x.end()
  12. #define PI acos(-1)
  13. #define sin(x) sin((x)*PI/180)
  14. #define cos(x) cos((x)*PI/180)
  15. #define tan(x) tan((x)*PI/180)
  16. #define Ones(x) __builtin_popcountll(x)
  17.  
  18. using namespace std;
  19.  
  20. void solve()
  21. {
  22. int n;
  23. cin>>n;
  24. bool prime[n+1];
  25. memset(prime,true,sizeof(prime));
  26. vector<ll>cnt(n+1);
  27. for(int i=2; i<=n; i++)
  28. {
  29. if(prime[i])
  30. {
  31. for(int k=i+i; k<=n; k+=i)
  32. {
  33. cnt[k]++;
  34. prime[k]=false;
  35. }
  36. }
  37. }
  38. int c=0;
  39. for(int i=2; i<=n; i++)
  40. {
  41. if(cnt[i]==2)
  42. {
  43. c++;
  44. }
  45. }
  46. cout<<c<<endl;
  47. }
  48.  
  49. int main()
  50. {
  51. Kirlos
  52. ll t;
  53. t=1;
  54. //cin>>t;
  55. while(t--)
  56. {
  57. solve();
  58. }
  59. return 0;
  60. }
Success #stdin #stdout 0.01s 5516KB
stdin
Standard input is empty
stdout
12104