标签:
b以内的合数
1 //对区间[a,b)内的整数执行筛法,需要保证a>1。is_prime[i-a]表示整数i是素数。 2 void segment_sieve(LL a, LL b) 3 { 4 for (LL i = 0; i*i < b; i++) is_prime_small[i] = true; 5 for (LL i = 0; i < b - a; i++) is_prime[i] = true; 6 7 for (LL i = 2; i*i < b; i++){ 8 if (is_prime_small[i]){ 9 for (LL j = 2 * i; j*j < b; j += i) is_prime_small[j] = false; 10 for (LL j = max(2LL, (a + i - 1) / i)*i; j < b; j += i) is_prime[j - a] = false; 11 } 12 } 13 }
例题 POJ 3978
标签:
原文地址:http://www.cnblogs.com/cumulonimbus/p/5818951.html