fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. bool p[(int)1e7+5];
  4.  
  5. void check(int x, int k){
  6. // cout << "k: " << k << endl;
  7. for(int i = 2; i <= k; i++){
  8. if(p[i] == false){
  9. for(int j = i; j <= x; j += i){
  10. p[j] = true;
  11. }
  12. }
  13. }
  14. // for(int i = 1; i <= x; i++){
  15. // cout << i << " " << p[i] << endl;
  16. // }
  17. }
  18.  
  19.  
  20. int main() {
  21. int t,a,k;
  22. cin >> t >> a >> k;
  23. int x = t/a;
  24. check(x, k);
  25. int cnt = 0;
  26. for(int i = 1; i <= x; i++){
  27. if(p[i] == false) cnt++;
  28. }
  29. cout << cnt << "\n";
  30. return 0;
  31. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
0