C++ 输入输出加速挂(ACM竞赛常用)

好多种版本,今天给出其中之一,也是比较快的一种。 

int read() {
	char ch = getchar();
	int num = 0;
	bool fl = 0;
	for(; !isdigit(ch); ch = getchar())
		if (ch=='-') fl = 1;
	for(; isdigit(ch); ch = getchar())
		num = (num<<1)+(num<<3)+ch-48;
	if(fl) num = -num;
	return num;
}
inline int read() {
    char ch = getchar(); int x = 0, f = 1;
    while(ch < '0' || ch > '9') {
        if(ch == '-') f = -1;
        ch = getchar();
    } while('0' <= ch && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    } return x * f;
}

__int128相关知识点

 

再来个超快版本:(真の超快,用这个板子在vj上刷到了好多榜一)

inline char nc() {
	static char buf [100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline int read() {
	static char c=nc(); int x=0,f=1;
	for(;c>'9'||c<'0';c=nc()) if(c=='-') f=-1;
	for(;c<='9'&&c>='0';c=nc()) x=(x<<3)+(x<<1)+c-48;
	return x*f;
}

 

你可能感兴趣的:(知识点)