fork download
  1. #include <iostream> // PRIME_10k.cpp DANILIN
  2. #include <cmath> // rextester.com/ZUNIGB54689
  3. using namespace std; int main() // 104743
  4. { setlocale (LC_ALL, "RUS"); srand(time(NULL));
  5. int max=10004, n=1, p=1; int f, j; double s;
  6. while (n <= max)
  7. { f=0; j=2; s = int (pow(p, 0.5));
  8. while (f < 1)
  9. { if (j >= s) f=2;
  10. if (int(p) % int(j) == 0) f=1;
  11. j++;
  12. }
  13. if (f != 1) { n++; } // cout << n <<" "<< p << endl;
  14. p++;
  15. }
  16. cout << n-1 <<" "<< p-1 << endl;
  17. system("pause");
  18. }
  19.  
Success #stdin #stdout #stderr 0.02s 5288KB
stdin
Standard input is empty
stdout
10004 104773
stderr
sh: 1: pause: not found