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

· · 题解

solution

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

code

#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;
}