ruhan008

sieve

Sep 29th, 2025
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. {
  2. "": {
  3. "prefix": "cd_sieve",
  4. "body": [
  5. "const int N = 2e5 + 10;",
  6. "vector<bool> isPrime(N, 1);",
  7. "// vector<int> primes;",
  8. "",
  9. "// call sieve() in main",
  10. "void sieve(){",
  11. " isPrime[0] = isPrime[1] = 0;",
  12. "",
  13. " for(int i = 2; i < N; i++){",
  14. " if(isPrime[i]){",
  15. " // primes.push_back(i);",
  16. "",
  17. " for(int j = 2 * i; j < N; j += i) {",
  18. " isPrime[j] = 0;",
  19. " }",
  20. " }",
  21. " }",
  22. "}"
  23. ],
  24. "description": ""
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment