#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
inline __int128 read()
{
__int128 x = 0;
__int128 f = 1;
char ch = getchar();
while (ch < '0' || ch > '9')
{
if (ch = '-')
{
f = -1;
}
ch = getchar();
}
while (ch >= '0' && ch <= '9')
{
x = x * 10 + ch - '0';
ch = getchar();
}
return x * f;
}
inline void write(__int128 x)
{
if (x < 0)
{
putchar('-');
x = -x;
}
if (x > 9)
write(x / 10);
putchar(x % 10 + '0');
}
int main()
{
__int128 a;
a = read();
__int128 nums[a + 1];
__int128 i, j;
__int128 count = 0;
for (i = 2; i <= a; i++)
{
nums[i] = 1;
}
for (i = 2; i <= sqrt(a); i++)
{
if (nums[i] == 1)
{
for (j = 2 * i; j <= a; j++)
{
if (nums[j] == 0)
continue;
if (!(j % i))
{
nums[j] = 0;
}
}
}
}
for (i = 2; i <= a; i++)
{
if (nums[i])
{
write(i);
cout << " ";
count++;
if (!(count % 20))
{
cout << endl;
}
}
}
}
求素数,要求满足128bit的整数,但是7位整数就运行不了了,怎么解决
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
0条回答 默认 最新
悬赏问题
- ¥15 为啥画版图在Run DRC会出现Connect Error?可我Calibre的hostname和计算机的hostname已经设置成一样的了。
- ¥20 网站后台使用极速模式非常的卡
- ¥20 Keil uVision5创建project没反应
- ¥15 mmseqs内存报错
- ¥15 vika文档如何与obsidian同步
- ¥15 华为手机相册里面的照片能够替换成自己想要的照片吗?
- ¥15 陆空双模式无人机飞控设置
- ¥15 sentaurus lithography
- ¥100 求抖音ck号 或者提ck教程
- ¥15 关于#linux#的问题:子进程1等待子进程A、B退出后退出(语言-c语言)