快读

· · 个人记录

#include <iostream>
#include <cstring>

using namespace std;

namespace Fast_read
{
    // int -2147483648~2147483647
    // 如果输入输出会有 -2147483648 (2^31) 记得开 long long
    // 只输入大写字母或小写字母可以修改快读字符串 
    // 空格换行自己输 
    int Fop, Fstk[35], Ftop = 0;
    char Fc;

    template <typename T>
    inline void read(T &Fw)
    {
        Fw = 0, Fop = 1;
        do {Fc = getchar();}while ((Fc < '0' || Fc > '9') && Fc != '-');
        if (Fc == '-') Fop = -1, Fc = getchar();
        do {Fw = (Fw << 1) + (Fw << 3) + (Fc ^ 48), Fc = getchar();}while (Fc >= '0' && Fc <= '9');
        Fw *= Fop;
    }

    inline int read()
    {
        int Fw = 0;
        Fop = 1;
        do {Fc = getchar();}while ((Fc < '0' || Fc > '9') && Fc != '-');
        if (Fc == '-') Fop = -1, Fc = getchar();
        do {Fw = (Fw << 1) + (Fw << 3) + (Fc ^ 48), Fc = getchar();}while (Fc >= '0' && Fc <= '9');
        return Fw * Fop;
    }

    template <typename T>
    inline void print(T ans)
    {
        Ftop = 0;
        if (ans < 0) putchar('-'), ans = -ans;
        do {Fstk[ ++ Ftop] = ans % 10, ans /= 10;}while (ans);
        while (Ftop) putchar(Fstk[Ftop -- ] ^ 48);
    }

    inline void read(char *s, int &len)
    {
        do {Fc = getchar();}while ((Fc < 'a' || Fc > 'z') && (Fc < 'A' || Fc > 'Z'));
        do {s[ ++ len] = Fc, Fc = getchar();}while ((Fc >= 'a' && Fc <= 'z') || (Fc >= 'A' && Fc <= 'Z'));
    }

    inline void print(char *s, int &len)
    {
        Ftop = 0;
        do {putchar(s[ ++ Ftop]);}while (Ftop <= len);
    }

    inline void read(char *s, int &len)
    {
        do {Fc = getchar();}while (Fc < '0' || Fc > '1');
        do {s[ ++ len] = Fc, Fc = getchar();}while (Fc == '0' || Fc == '1');
    }
}

using namespace Fast_read;