快读快输模板
灰鹤在此
·
·
个人记录
/*-------------------------fast io begin-------------------------*/
namespace Fread{
const int SIZE=1<<16;
char buf[SIZE],*S,*T;
inline char getchar(){
if(S==T){
T=(S=buf)+fread(buf,1,SIZE,stdin);
if(S==T)return '\n';
}return *S++;
}
}
namespace Fwrite{
const int SIZE=1<<16;
char buf[SIZE],*S=buf,*T=buf+SIZE;
inline void flush(){fwrite(buf,1,S-buf,stdout);S=buf;}
inline void putchar(char c){
*S++=c;if(S==T)flush();
}
struct HuiHe{~HuiHe(){flush();}}GreyCrane;
}
#define getchar Fread::getchar
#define putchar Fwrite::putchar
template<typename T>inline void read(T&x){
x=0;T 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;
}
const double __10[20]={1,1e-1,1e-2,1e-3,1e-4,1e-5,1e-6,1e-7,1e-8,1e-9,1e-10,1e-11,1e-12,1e-13,1e-14,1e-15,1e-16,1e-17,1e-18,1e-19};
inline void read(double&x){
x=0;double f=1;char c=getchar();
while(!isdigit(c)){if(c=='-')f=-f;c=getchar();}
while(isdigit(c))x=x*10+(c^48),c=getchar();
if(c^'.'){x*=f;return ;}else c=getchar();int cnt=0;
while(isdigit(c))x+=(c^48)*__10[++cnt],c=getchar();
x*=f;
}
inline void read(long double&x){
x=0;long double f=1;char c=getchar();
while(!isdigit(c)){if(c=='-')f=-f;c=getchar();}
while(isdigit(c))x=x*10+(c^48),c=getchar();
if(c^'.'){x*=f;return ;}else c=getchar();int cnt=0;
while(isdigit(c))x+=(c^48)*__10[++cnt],c=getchar();
x*=f;
}
inline void read(__float128&x){
x=0;__float128 f=1;char c=getchar();
while(!isdigit(c)){if(c=='-')f=-f;c=getchar();}
while(isdigit(c))x=x*10+(c^48),c=getchar();
if(c^'.'){x*=f;return ;}else c=getchar();int cnt=0;
while(isdigit(c))x+=(c^48)*__10[++cnt],c=getchar();
x*=f;
}
inline void read(char*s){
int len=0;char c=getchar();
while(c==' '||c=='\n'||c=='\r')c=getchar();
while(c!=' '&&c!='\n'&&c!='\r')s[len++]=c,c=getchar();
s[len]='\0';
}
inline void read(string&s){
s="";char c=getchar();
while(c==' '||c=='\n'||c=='\r')c=getchar();
while(c!=' '&&c!='\n'&&c!='\r')s+=c,c=getchar();
}
template<class T>inline void read(vector<T>&a){for(auto&x:a)read(x);}
template<class T1,class T2>inline void read(pair<T1,T2>a){read(a.first),read(a.second);}
template<typename T>inline void write(T x){
if(x==0){putchar(48);return ;}
if(x<0)putchar('-'),x=-x;
static int sta[45];int top=0;
while(x)sta[++top]=x%10,x/=10;
while(top)putchar(sta[top--]+48);
}
inline void write(double x,int len){
if(x<0)putchar('-'),x=-x;
x+=5*__10[len+1];
long long y=x;x-=(double)y;static int sta[45];int top=0;
while(y)sta[++top]=y%10,y/=10;
if(!top)putchar('0');
while(top)putchar(sta[top--]+48);putchar('.');
for(int i=0;i<len;i++)x*=10;
y=x;
while(y)sta[++top]=y%10,y/=10;
for(int i=0;i<len-top;i++)putchar('0');
while(top)putchar(sta[top--]+48);
}
inline void write(long double x,int len){
if(x<0)putchar('-'),x=-x;
x+=5*__10[len+1];
long long y=x;x-=(long double)y;static int sta[45];int top=0;
while(y)sta[++top]=y%10,y/=10;
if(!top)putchar('0');
while(top)putchar(sta[top--]+48);putchar('.');
for(int i=0;i<len;i++)x*=10;
y=x;
while(y)sta[++top]=y%10,y/=10;
for(int i=0;i<len-top;i++)putchar('0');
while(top)putchar(sta[top--]+48);
}
inline void write(__float128 x,int len){
if(x<0)putchar('-'),x=-x;
x+=5*__10[len+1];
__int128 y=x;x-=(__float128)y;static int sta[45];int top=0;
while(y)sta[++top]=y%10,y/=10;
if(!top)putchar('0');
while(top)putchar(sta[top--]+48);putchar('.');
for(int i=0;i<len;i++)x*=10;
y=x;
while(y)sta[++top]=y%10,y/=10;
for(int i=0;i<len-top;i++)putchar('0');
while(top)putchar(sta[top--]+48);
}
inline void write(char c){putchar(c);}
inline void write(char*s){int len=strlen(s);for(int i=0;i<len;i++)putchar(s[i]);}
inline void write(const char*s){int len=strlen(s);for(int i=0;i<len;i++)putchar(s[i]);}
inline void write(string s){for(auto x:s)putchar(x);}
template<class T>inline void write(vector<T>a){
for(int i=0;i<(int)a.size()-1;i++)write(a[i]),write(' ');
write(a[(int)a.size()-1]);
}
template<class T1,class T2>inline void write(pair<T1,T2>a){write(a.first),write(' '),write(a.second);}
/*-------------------------fast io end-------------------------*/