说明#
__int128 is only supported by 64-bit GCC and G++ and is not part of the C++ standard. It can be directly used if you are using 64-bit GCC.
In the Supplementary Explanation on the Use Restrictions of Programming Languages in the NOI Series Activities, it is stated:
Library functions or macros starting with an underscore are allowed, except for library functions and macros that are explicitly prohibited.
Therefore, __int128 can be used in competitions.
存储范围#
__int128 occupies 128 bytes of space, and the data range is
.
The precise range is , with a magnitude of around .
使用方式#
声明定义#
Same as other types: type name
__int128 a=4,b=3;
a=10;
a+=b;
a*=b;
...
输入输出#
Since it is not part of the C++ standard, there are no corresponding input and output tools available, and you cannot directly use scanf, printf, cin, cout for processing. You need to write your own input and output functions.
输入#
void read(__int128 &ans){
__int128 x,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();
}
ans=x*f;
}
输出#
void output(__int128 x){
if(x<0){
putchar('-');
x*=-1;
}
int ans[35]={0},top=0;
do{
ans[top++]=x%10;
x/=10;
}while(x);
while(top){
putchar(ans[--top]+'0');
}
}