Grimgod IO

· · 个人记录

前言

$GrimgodIO$除了支持超快速读写外,还支持$\gcd$和快速幂等操作,具体使用方法后面会讲。 # 正题 ```cpp namespace GrimgodIO{ char buf[1<<20],*p1,*p2; #define getchar() (p1==p2?(p2=buf+fread(p1=buf,1,1<<20,stdin),p1==p2?EOF:*p1++):*p1++) int w=5;inline void setw(int x){w=x;return;} template<typename T>inline void readn(T &x){ x=0;bool f=false;char c=getchar(); while(c<'0'||c>'9'){if(c=='-') f=true;c=getchar();} while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar(); x=f?-x:x;return; } template<typename T>inline void read(T &x){ if(typeid(x)==typeid(int)){readn(x);return;} if(typeid(x)==typeid(long long)){readn(x);return;} if(typeid(x)==typeid(unsigned long long)){readn(x);return;} if(typeid(x)==typeid(__int128)){readn(x);return;} else std::cin>>x; return; } template<>inline void read<double>(double &x){ x=0;double y=1;bool f=false,g=false;char c=getchar(); while(c<'0'||c>'9'){if(c=='-') f=true;c=getchar();} while((c>='0'&&c<='9')||c=='.'){if(c=='.'){g=true,c=getchar();continue;} if(g) y/=10,x+=(c^48)*y;else x=x*10+(c^48);c=getchar();} x=f?-1*x:x; return; } template<>inline void read<std::string>(std::string &x){ x="";char c=getchar();while(c==' '||c=='\n') c=getchar(); while(c!=' '&&c!='\n') x=x+c,c=getchar(); return; } template<>inline void read<char>(char &x){x=getchar(); while(x==' '||x=='\n') x=getchar();return;} template<typename T>inline void writen(T x){ if(x<0){putchar('-');x=-x;}if(x/10) writen(x/10); putchar((x%10)^48);return;} template<typename T>inline void write(T x){ if(typeid(x)==typeid(int)){writen(x);return;} if(typeid(x)==typeid(long long)){writen(x);return;} if(typeid(x)==typeid(unsigned long long)){writen(x);return;} if(typeid(x)==typeid(__int128)){writen(x);return;} else std::cout<<x; return; } template<>inline void write<double>(double x){ std::cout<<std::fixed<<std::setprecision(w)<<x; return; } template<>inline void write<std::string>(std::string x){ for(register int i=0;i<x.size();++i) putchar(x[i]); return; } template<>inline void write<char>(char x){putchar(x);return;} template<typename T,typename... S>inline void read(T &x,S &...y){ read(x),read(y...); return; } template<typename T,typename... S>inline void write(T x,S... y){ write(x),write(y...); return; } template<typename T>inline T Max(T x,T y){ if(x<y) return y; return x; } template<typename T>inline T Min(T x,T y){ if(x<y) return x; return y; } inline long long binpow(long long a,long long b,long long mod){ long long res=0; while(b) {if(b&1) res=res*a%mod;a=a*a%mod,b>>=1;} return res; } inline long long gcd(long long a,long long b){ if(a%b==0) return b; return gcd(b,a%b); } } using GrimgodIO::read;using GrimgodIO::write;using GrimgodIO::setw; using GrimgodIO::Max;using GrimgodIO::Min;using GrimgodIO::binpow;using GrimgodIO::gcd; ```