fork(8) download
  1. #include <iostream>
  2. #include <cmath>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. const size_t b = 1000000;
  10. size_t a=2, k=1, i=0, j=0, cnt=0;
  11.  
  12. vector<int> s;
  13. s.resize(b+1, 0);
  14.  
  15. for( i=2; i <= b; i+=2 ) { s[i]=1; }
  16.  
  17. for( i=3; i <= b; i+=2 ) {
  18. if( s[i]==0 ) {
  19. for( j=i; j <= b; j+=i ) { s[j]+=1; }
  20. }
  21. }
  22. for( i=a; i <= b; ++i ) {
  23. if( s[i]==k ) {
  24. ++cnt;
  25. }
  26. }
  27. cout << endl << " the result is: "
  28. << cnt << endl;
  29.  
  30. return 0;
  31. }
Success #stdin #stdout 0.03s 3340KB
stdin
Standard input is empty
stdout
 the result is: 78734