自制有用工具

· · 个人记录

快速读入

:::info[代码]

//快速读入
namespace mqy_std{
    class fast_io{
        template<typename Type>
        void pwrite(Type n) const{
            if(n<0)putchar('-'),n*=-1;
            if(n==0)return;
            pwrite(n/10);
            putchar((char)(n%10+'0'));
        }
    public:
        template<typename Type = int>
        Type read() const{
            Type x=0,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();
            return x*f;
        }
        template<typename Type>
        void read(Type &n) const{
            Type x=0,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();
            n=x*f;
        }
        template<typename Type>
        void write(Type n) const{
            if(n==0){cout<<0;return;}
            pwrite(n);
        }
    };
    const static fast_io io;
}

:::