Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int LIMIT = 1000000;
- int sieve[LIMIT + 1];
- int primes[LIMIT + 1];
- int L[LIMIT+1];
- int primeCount = 1;
- void gensieve() {
- CLR(sieve, 0);
- for (int i = 2; i <= LIMIT; i++) {
- if (!sieve[i]) {
- primes[primeCount] = i;
- sieve[i] = primeCount++;
- }
- for (int j = 1; j <= sieve[i] && i * primes[j] <= LIMIT; j++) {
- sieve[i * primes[j]] = j;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement