从之前所说的我们知道还有一个比getchar更快的函数,接下来我们再用fread去实现getchar,实现一个更快的快读。 1. char buf[100000], * p1 = buf, * p2 = buf;2.3. inline char nc() {4. if(p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1, stdin);5. return *p1++;6. }7.8. inline...
快读快输 快速读入 template <typename T> void read (T &x) { T f = 1; x = 0; char tem = getchar (); while (tem < '0' || tem > '9') { if (tem == '-') f = -1; tem = getchar (); } while (tem >= '0' && tem <= '9') { x = (x << 1) + (x <<...
}inlinevoidreadln(string &s){s=readln();}//这个没测试过,理论上会快一点吧inlinevoidprints(string &s){for(charc:s)putchar(c);}#defineisdigit(x) ((x)>='0'&&(x)<='9')//用法 变量=read<类型名>();template<classT>inlineTread(){ T x=0,f=1;charc=getchar();for(;!isdigit(c)...