跳转至

介绍 __int128_t

一般将 __int128_t 定义成 int128

typedef __int128_t int128;

qread 快读

inline int128 qread()
{
    int128 x = 0, f = 1; char c = getchar();
    while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); }
    while (c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); }
    return x * f;
}

qwrite 快输

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

运算

支持整数的一般运算。

一般可用于防溢出 long long 型乘法:

// 防止溢出 LL 的乘法
inline LL qmul(int128 a, int128 b, LL p)
{
    return a * b % p;
}