跳到正文

剪贴板

剪贴板 vhz8bp2o

原文
剪贴板信息

剪贴板信息

收录
更新

别人大佬的流快读

C++
struct control{
	int ct,val;
	control(int Ct,int Val=-1):ct(Ct),val(Val){}
	inline control operator()(int Val){
		return control(ct,Val);
	}
}_endl(0),_prs(1),_setprecision(2);
struct FastIO{
	#define IOSIZE 1000000
	char in[IOSIZE],*p,*pp,out[IOSIZE],*q,*qq,ch[20],*t,b,K,prs;
	FastIO():p(in),pp(in),q(out),qq(out+IOSIZE),t(ch),b(1),K(6){}
	~FastIO(){fwrite(out,1,q-out,stdout);}
	inline char getch(){
		return p==pp&&(pp=(p=in)+fread(in,1,IOSIZE,stdin),p==pp)?b=0,EOF:*p++;
	}
	inline void putch(char x){
		q==qq&&(fwrite(out,1,q-out,stdout),q=out),*q++=x;
	}
	inline void puts(const char str[]){fwrite(out,1,q-out,stdout),fwrite(str,1,strlen(str),stdout),q=out;}
	inline void getline(string& s){
		s="";
		for(reg char ch;(ch=getch())!='\n'&&b;)s+=ch;
	}
	#define indef(T) inline FastIO& operator>>(T& x){\
		x=0;reg char f=0,ch;\
		while(!isdigit(ch=getch())&&b)f|=ch=='-';\
		while(isdigit(ch))x=(x<<1)+(x<<3)+(ch^48),ch=getch();\
		return x=f?-x:x,*this;\
	}
	indef(int)
	indef(long long)
	inline FastIO& operator>>(char& ch){return ch=getch(),*this;}
	inline FastIO& operator>>(string& s){
		s="";reg char ch;
		while(isspace(ch=getch())&&b);
		while(!isspace(ch)&&b)s+=ch,ch=getch();
		return *this;
	}
	inline FastIO& operator>>(double& x){
		x=0;reg char f=0,ch;
        double d=0.1;
        while(!isdigit(ch=getch())&&b)f|=(ch=='-');
        while(isdigit(ch))x=x*10+(ch^48),ch=getch();
        if(ch=='.')while(isdigit(ch=getch()))x+=d*(ch^48),d*=0.1;
        return x=f?-x:x,*this;
	}
	#define outdef(_T) inline FastIO& operator<<(_T x){\
		!x&&(putch('0'),0),x<0&&(putch('-'),x=-x);\
		while(x)*t++=x%10+48,x/=10;\
		while(t!=ch)*q++=*--t;\
		return *this;\
	}
	outdef(int)
	outdef(long long)
	inline FastIO& operator<<(char ch){return putch(ch),*this;}
	inline FastIO& operator<<(const char str[]){return puts(str),*this;}
	inline FastIO& operator<<(const string& s){return puts(s.c_str()),*this;}
	inline FastIO& operator<<(double x){
		reg int k=0;
		this->operator<<(int(x));
		putch('.');
		x-=int(x);
		prs&&(x+=5*pow(10,-K-1));
		while(k<K)putch(int(x*=10)^48),x-=int(x),++k;
		return *this;
	}
	inline FastIO& operator<<(const control& cl){
		switch(cl.ct){
			case 0:putch('\n');break;
			case 1:prs=cl.val;break;
			case 2:K=cl.val;break;
		}
	}
	inline operator bool(){return b;}
}io;

我的测试中的带double的:

C++
namespace io{const int E=2;char buf[1<<20],*p1=buf,*p2=buf;inline char gc(){return(p1==p2&&(p2=(p1=buf)+cin.rdbuf()->sgetn(buf,1<<20),p1==p2)?EOF:*p1++);}inline void pc(const char x){cout.rdbuf()->sputc(x);}template<typename T>inline void read(T&x){x=0;char f=0,c;while(!isdigit(c=gc()))f|=c=='-';while(isdigit(c))x=(x*10+c-'0'),c=gc();x=f?-x:x;}inline void read(double&x){x=0;char f=0,c;double d=0.1;while(!isdigit(c=gc()))f|=c=='-';while(isdigit(c))x=(x*10+c-'0'),c=gc();if(c=='.')while(isdigit(c=gc()))x+=d*(c^48),d*=0.1;x=f?-x:x;}template<typename T=int>inline T read(){T s=0;char f=0,c=gc();while(!isdigit(c=gc()))f|=c=='-';while(isdigit(c))s=s*10+c-'0',c=gc();return f?-s:s;}inline void read(char*s){char c;while(isspace(c=gc()));while(!isspace(c))*s++=c,c=gc();}template<typename T>inline void write(T x){static char S[150];x<0&&(pc('-'),x=-x);int p=0;do{S[p++]=x%10^48;x/=10;}while(x);while(p--)cout.rdbuf()->sputc(S[p]);}inline void write(double x){write(int(x)),pc('.'),x-=int(x),x+=5*pow(10,-E-1);int p=0;while(p<E)pc(int(x*=10)^48),x-=int(x),++p;}inline void write(char*s){do{cout.rdbuf()->sputc(*s++);}while(*s);}inline void write(const char*s){do{cout.rdbuf()->sputc(*s++);}while(*s);}template<typename T>inline void writeln(const T x){write(x);pc(10);}template<typename T>inline void writesp(const T x){write(x);pc(' ');}template<typename T,typename...Args>inline void read(T&x,Args&...args){read(x),read(args...);}template<typename T,typename...Args>inline void write(T&x,Args&...args){write(x),pc(' '),write(args...);}}using namespace io;