适用于连unsigned long long也无法表示的大整数,由于标准输入输出中没有这个类型,所以需要自己手写输入和输出。
提交的时候选g++
输入:
inline __int128 read(){
__int128 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;
}
输出:
inline void print(__int128 x){
if(x<0){
putchar('-');
x=-x;
}
if(x>9)
print(x/10);
putchar(x%10+'0');
}
本文介绍了一种处理超大整数(如__int128类型)的手动输入输出方法,适用于连unsigned long long都无法表示的情况。文章提供了具体的代码实现,包括读取 (__int128) 和打印 (__int128) 的内联函数。
2938

被折叠的 条评论
为什么被折叠?



