fork download
  1. /*input
  2. 1
  3. 10
  4. */
  5. #include<bits/stdc++.h>
  6. using namespace std;
  7. const int N=1e6 + 100;
  8. #define int long long
  9. #define pii pair<int, int>
  10. #define f first
  11. #define s second
  12. inline pii mp(int a, int b)
  13. {
  14. pii temp;temp.f=a;temp.s=b;return temp;
  15. }
  16. vector<bool> isp(N, 1);int pref[N];
  17. signed main()
  18. {
  19. //freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
  20. ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  21. isp[1]=0;
  22. for(int i=2;i<N;i++)
  23. {
  24. if(isp[i])
  25. {
  26. for(int j=i*i;j<N;j+=i) isp[j]=0;
  27. }
  28. }
  29. pref[1]=0;
  30. for(int i=2;i<N;i++){
  31. pref[i]=pref[i-1];
  32. if(isp[i]) pref[i]++;
  33. }
  34. int q;cin>>q;
  35. while(q--)
  36. {
  37. int n;cin>>n;
  38. cout<<pref[n]<<endl;
  39. }
  40. }
Success #stdin #stdout 0.01s 23184KB
stdin
Standard input is empty
stdout
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0