输入输出:
C/C++标准IO是不认识__int128这种数据类型的,因此要自己实现IO,其他的运算,与int没有什么不同。
#include <bits/stdc++.h>
using namespace std;
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 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();
write(a);
return 0;
}
附:
inline定义的类的内联函数,函数的代码被放入符号表中,在使用时直接进行替换,没有了调用的开销,效率也很高。(以空间换取时间)
参考资料
https://blog.youkuaiyun.com/tianwei0822/article/details/80687466