跳到正文

个人记录

祖传专利超快读

Cute_lxy约 2 分钟
原文
文章信息与版本

文章信息

发布
2022年7月12日
收录
2025年12月12日
更新
2026年11月12日
篇幅
约 2 分钟

版本

  1. v1当前
C++
namespace io
{
	char buf[1<<21],*p1=buf,*p2=buf;
	inline int getc()
	{
    	return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;
	}
	template<typename T1>
	inline void read(T1& x)
	{
		x=0;int f=1;char ch=getc();
		while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getc();}
		while(ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getc();}
		x*=f;
	}
	template<typename T1,typename ...Args>
	inline void read(T1& x,Args& ...args)
	{
	    read(x);read(args...);
	}
	char buff[1<<21];
	int pa=-1;
	const int pb=(1<<21)-1;
	inline void fl()
	{
    	fwrite(buff,1,pa+1,stdout);
    	pa = -1;
	}//需要在main()函数结尾调用!!!
	inline void putc(const char &x)
	{
    	if(pa == pb)fl();
    	buff[++pa]=x;
    }
	template<typename T1>
	inline void print(T1 x)
    {
		static char st[35];
		int tp=0;
		if(x<0){putc('-'),x=-x;}
		if(x==0) putc('0');
		while(x)st[++tp]=(x%10)|48,x/=10; 
		while(tp)putc(st[tp--]);
		putc('\n');
    }
	template<typename T1,typename ...Args>
	inline void print(T1 x,Args ...args)
	{
		write(x);write(args...);
	}
}
using namespace io;
原文