素数筛法
代码就放这里,解释见注释。
char pend[100000005];
int odd[7123456];
void count()
{
int count = 1;
/* 定义 */
pend[1] = 1; //特判
for (int i = 2; i * i <= 100000005; i++)
{
if (!pend[i])
{
for (int j = i * i; j <= 100000005; j += i)
{
pend[j] = 1;
}
}
}
/* 线筛 */
for (int i = 1; i < 100000005; i++)
{
if (!pend[i])
{
odd[count++] = i;
}
}
/* 储存 */
return;
}