跳到正文

题解

题解:P10815 【模板】快速读入

Qfaiser约 1 分钟
原文
文章信息与版本

文章信息

发布
2024年7月28日
收录
2026年7月31日
更新
2026年11月13日
篇幅
约 1 分钟
题目
P10815

版本

  1. v1当前

solution

终于有快读模版了,背下来就行。

code

C++
#include <bits/stdc++.h>
using namespace std;
char buf[1<<20],*p1=buf,*p2=buf,sr[1<<23],z[23],nc;int C=-1,Z=0,Bi=0;
#define gc() p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++
int read(){
		int x=0,y=1;
		while(nc=gc(),(nc<48||nc>57)&&nc!=-1)if(nc==45)y=-1;Bi=1;
		x=nc-48;
		while(nc=gc(),47<nc&&nc<58)x=(x<<3)+(x<<1)+(nc^48),Bi++;
		return x*y;
	}
int main () {
	int n=read();
	long long ans=0;
	for (int i=1; i<=n; i++)
		ans+=read();
	cout << ans;
	return 0;
}
原文