跳到正文

科技·工程

快读快写

microsoft_vs_code约 4 分钟
原文

这是 2026年8月16日 存档的第 1 版,不是当前版本。查看当前版本

文章信息与版本

文章信息

发布
2026年8月16日
收录
2026年8月16日
更新
2026年10月18日
篇幅
约 4 分钟

版本

  1. v2当前
  2. v1
C++
namespace FASTIO
{
    char *left, *right, s[100000];
    uint8_t out[(1 << 22) + (1 << 5)], c[1 << 5], *now = out;
    #define gtchar() (left == right && (right = (left = s) + fread(s, 1, 100000, stdin), left == right) ? EOF : *left++)
    #define ptchar(x) (now++[0] = (x))
    ll read()
    {
        char a = gtchar();
        ll ans = 0, f = 1;
        while (a < '0' || a > '9')
        {
            if (a == '-')
                f = -1;
            a = gtchar();
        }
        while (a >= '0' && a <= '9')
        {
            ans = (ans << 3) + (ans << 1) + (a ^ 48);
            a = gtchar();
        }
        return ans * f;
    }
    void write(ll x)
    {
        if (!x)
        {
            ptchar('0');
            return;
        }
        uint8_t *cnt = c + 32;
        (x < 0) && (now++[0] = 45, x = -x);
        (x) && ((--cnt)[0] = x % 10 ^ 48, x /= 10),
            (x) && ((--cnt)[0] = x % 10 ^ 48, x /= 10),
            (x) && ((--cnt)[0] = x % 10 ^ 48, x /= 10),
            (x) && ((--cnt)[0] = x % 10 ^ 48, x /= 10),
            (x) && ((--cnt)[0] = x % 10 ^ 48, x /= 10),
            (x) && ((--cnt)[0] = x % 10 ^ 48, x /= 10),
            (x) && ((--cnt)[0] = x % 10 ^ 48, x /= 10),
            (x) && ((--cnt)[0] = x % 10 ^ 48, x /= 10),
            (x) && ((--cnt)[0] = x % 10 ^ 48, x /= 10),
            (x) && ((--cnt)[0] = x % 10 ^ 48, x /= 10),
            (x) && ((--cnt)[0] = x % 10 ^ 48, x /= 10),
            (x) && ((--cnt)[0] = x % 10 ^ 48, x /= 10),
            (x) && ((--cnt)[0] = x % 10 ^ 48, x /= 10),
            (x) && ((--cnt)[0] = x % 10 ^ 48, x /= 10),
            (x) && ((--cnt)[0] = x % 10 ^ 48, x /= 10),
            (x) && ((--cnt)[0] = x % 10 ^ 48, x /= 10),
            (x) && ((--cnt)[0] = x % 10 ^ 48, x /= 10),
            (x) && ((--cnt)[0] = x % 10 ^ 48, x /= 10),
            (x) && ((--cnt)[0] = x % 10 ^ 48, x /= 10);
        memmove(now, cnt, c + 32 - cnt);
        now += c + 32 - cnt;
        if (now - out > (1 << 22))
        {
            fwrite(out, 1, now - out, stdout);
            now = out;
        }
    }
    #undef gtchar
};

需要在程序末尾也 fwrite(out, 1, now - out, stdout); 一下。