更加优秀的快读快输
_nothingGG · · 个人记录
template<typename T>inline void read(T &x){
x=0;int f=1;char c=getchar();
while(!isdigit(c)){if(c=='-')f=-f;c=getchar();}
while (isdigit(c)){x=x*10+(c-48);c=getchar();}
x*=f;
}
template<typename T,typename...Args>inline void read(T &x,Args&...y){read(x),read(y...);}
template<typename T>inline void write(T x,char ch=' '){
stack<char>st;
if(x<0)putchar('-'),x=-x;
if(x==0)putchar('0');
while(x)st.push(x%10+'0'),x/=10;
while(!st.empty())putchar(st.top()),st.pop();
putchar(ch);
}
template<typename...Args>inline void write(char ch,Args...y){write(y...,ch);}
输入时:read(a,b,c,d...);
输出时:write(x); 或 write('\n',a,b,c,d...);