c******f 发帖数: 2144 | 1 const int size = 1024;
bitset sieve;
sieve.flip();
int finalBit = sqrt(sieve.size())+1;
for (int i=2;i
if (sieve.test(i))
for(int j = 2*i;j
sieve.reset(j);
Question:
In this program we set all 1024 bits as all "1"(which means 1111...111)
here we will find 2 and set all numbers like 4, 6, 8, ...,10 to 0
then find 3 and set all numbers like 6,9,12...to 0
then find 4 and set all numbers like 8,12,...to 0
until the loop is finished, we will find | s*********t 发帖数: 1663 | 2 32的平方是1024
如果比32大的数能整除某个小于1024的数那么商肯定比32小,已经check过了
【在 c******f 的大作中提到】 : const int size = 1024; : bitset sieve; : sieve.flip(); : int finalBit = sqrt(sieve.size())+1; : for (int i=2;i: if (sieve.test(i)) : for(int j = 2*i;j: sieve.reset(j); : Question: : In this program we set all 1024 bits as all "1"(which means 1111...111)
| c******f 发帖数: 2144 | |
|