Advertisement
askarulytarlan

Решето эратосфена

Jan 22nd, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.  
  7. cin >> n;
  8.  
  9. was[0] = was[1] = true;
  10.  
  11. for (int i = 2; i <= 10000000; i++) {
  12. if (was[i] != true) {
  13. if (i * 1ll * i <= 10000000) {
  14. for (int j = i * i; j <= 10000000; j += i)
  15. was[j] = true;
  16. }
  17. }
  18.  
  19. }
  20.  
  21. return 0;
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement