关于__int128

参考:关于__int128

__int128本身可以进行的运算有+ - * / %还有各种位运算符
但是__int128不可以进行输入输出的操作,如果想要进行输入输出需要自定义函数
__int128可以在 64 位的编译器中运行
亲测__int128大概最多能够储存 4e22 左右的数

输入:

void read(__int128 &x)
{
    x=0;
    int f=1;
    char ch;
    if ((ch=getchar())=='-') f=-f;
    else x=x*10+ch-'0';
    while ((ch=getchar())>='0'&&ch<='9') x=x*10+ch-'0';
    x*=f;
}

输出:

void print(__int128 x)
{
    if (x<0) x=-x, putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+'0');
}

__int128写快速乘:

__int128 _a,_b,_c;
ll mul(ll a,ll b,ll c)
{
    _a=a,_b=b,_c=c;
    return ll(_a*_b%_c);
}
posted @ 2019-08-15 15:44  caoanda  阅读(542)  评论(3编辑  收藏  举报