来自jp
关于__int128的使用
正常来说,unsigned long long已经是可以定义的最大的类型了,但是如果数据范围超过了 就会爆炸。如果要处理比其大一点又不是那么大的数,就可以使用 __int128这个定义。
NOI 及 CSP 系列中可以正常使用 __int128:
https://www.cnblogs.com/littlehb/p/15935662.html
__int128就是占用 128 字节的整数存储类型。由于是二进制,范围就是 ,如果使用了 unsigned __int128,则范围变成 (0) (2128)(0) (2128),即约39位数!
由于 __int128 仅仅是 (GCC)编译器内的东西,不在 (C++98/03/11/14/17/20)标准内,且仅 (GCC4.6)以上64位版本支持,很多配套都没有,只有四则运算功能, 所以要自己写输入输出。
注意:如何确定考试中能不能用 __int128呢?
办法就是先创建一个空白的cpp文件,然后使用 __int128 a,测试一下,编译器不报错就是可以。
#include <bits/stdc++.h>
using namespace std;
typedef __int128 LLL;
LLL read() {
LLL x = 0, 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;
}
void out(LLL x) {
if (x < 0) putchar('-'), x = -x;
if (x > 9) out(x / 10);
putchar(x % 10 + '0');
}
int main() {
LLL a, b;
a = read(), b = read();
out(a + b);
return 0;
}