关于快读
关于快读
我们在关于卡常里提到了快读,这里是一些方便(闲得慌)的写法
\(case\space 1\)
有时候要读多种类型,可以用 \(template\),这样只用写一个快读
template<typename T>
il void rd(T &x){
x=0;ri bool f=0;ri char c=getchar();
while(~c&&!isdigit(c)) f|=(c==45),c=getchar();
while(isdigit(c)) x=x*10+(c^48),c=getchar();
x=f?-x:x;
}
template<typename T>
il void wt(T x){
if(x<0) x=-x,putchar(45);
if(x>=10) wt(x/10);
return putchar(x%10|48),void();
}
\(case\space 2\)
一些没用的偷懒......可以一次读多个
template<typename T>
il void rd(T &x){
x=0;ri bool f=0;ri char c=getchar();
while(~c&&!isdigit(c)) f|=(c==45),c=getchar();
while(isdigit(c)) x=x*10+(c^48),c=getchar();
x=f?-x:x;
}
template<typename T,typename ...Args>
il void rd(T &a,Args &...args){rd(a),rd(args...);}
template<typename T>
il void wt(T x){
if(x<0) x=-x,putchar(45);
if(x>=10) wt(x/10);
return putchar(x%10|48),void();
}
template<typename T,typename ...Args>
il void wt(T a,Args &...args){wt(a),putchar(32),wt(args...);}
I went to the woods because I wanted to live deliberately, I wanted to live deep and suck out all the marrow of life, and not when I had come to die, discover that I had not live.