一些奇怪的东西以及寄几需要注意的地方

千万不要压行,代码不美观,程序可读性差,而且易犯玄学错误找不到错误。
long long不能乱开,乱开会导致玄学错误。

普通的快读

template <typename T>
inline void read(T &x) {
    x = 0; T fl = 1;
    char ch = 0;
    while (ch < '0' || ch > '9') {
        if (ch == '-') fl = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = (x << 1) + (x << 3) + (ch ^ 48);
        ch = getchar();
    }
    x *= fl;
}

cin和cout的崛起

class istream{
    char buf[15000003],*s;
    public:
        inline istream(){
            buf[fread(s=buf,1,15000001,stdin)]='\n';
            fclose(stdin);
        }
        template<typename T>
        inline istream&operator>>(T&rhs){
            for(rhs=0;!isdigit(*s);++s);
            while(isdigit(*s))rhs=rhs*10+(*s++&15);
            return*this;
        }
}cin;
struct ostream{
    char buf[8000005],*s;
    inline ostream(){s=buf;}
    inline void operator<<(long long d){
        if(!d){
            *s++='0';
        }else{
            static long long w;
            for(w=1;w<=d;w*=10);
            for(;w/=10;d%=w)*s++=d/w^'0';
        }
        *s++='\n';
    }
    inline ostream&operator<<(const char&c){*s++=c;return*this;}
    inline~ostream(){fwrite(buf,1,s-buf,stdout);}
}cout;

猜你喜欢

转载自www.cnblogs.com/chhokmah/p/10568083.html