1. 程式人生 > >【C++】終極讀入黑箱

【C++】終極讀入黑箱

採用fread的C++終極讀入黑箱

測速:待填坑

#include <bits/stdc++.h>
using namespace std;

class IO
{
	char buffer[10000001];
	char *h;
	int len;
	inline char gchar()
	{
		return *h++;
	}
	inline bool validdigit(char c)
	{
		return c>='0' && c<='9';
	}
public:
	inline void init()
	{
		len=fread(buffer,1,10000000,stdin);
		h=buffer;
	}
	inline int nextint()
	{
		register int i=0;
		register char c;
		do c=gchar();while(!validdigit(c));
		do{i=i*10+c-48;c=gchar();}while(validdigit(c));
		return i;
	}
	inline int nextsigned()
	{
		register int i=0,f=1;
		register char c;
		do{c=gchar();if(c=='-')f=-1;}while(!validdigit(c));
		do{i=i*10+c-48;c=gchar();}while(validdigit(c));
		return i*f;
	}
	inline long long nextlonglong()
	{
		register long long i=0;
		register char c;
		do c=gchar();while(!validdigit(c));
		do{i=i*10+c-48;c=gchar();}while(validdigit(c));
		return i;
	}
	inline long long nextsignedlonglong()
	{
		register long long i=0,f=1;
		register char c;
		do{c=gchar();if(c=='-')f=-1;}while(!validdigit(c));
		do{i=i*10+c-48;c=gchar();}while(validdigit(c));
		return i*f;
	}
	inline char nextchar()
	{
		register char c;
		do c=gchar();while(c<=' ');
		return c;
	}
};

int main()
{
}