读入挂
fastIO读入挂:
1 namespace fastIO{ 2 #define BUF_SIZE 100000 3 bool IOerror=0; 4 inline char nc(){ 5 static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE; 6 if(p1==pend){ 7 p1=buf; 8 pend=buf+fread(buf,1,BUF_SIZE,stdin); 9 if(pend==p1){ 10 IOerror=1; 11 return -1; 12 } 13 }return *p1++; 14 } 15 inline bool blank(char ch){ 16 return ch==' '||ch=='\n'||ch=='\r'||ch=='\t'; 17 } 18 inline bool read(int &x){ 19 char ch; 20 while(blank(ch=nc())); 21 if(IOerror)return 0; 22 for(x=ch-'0';(ch=nc())>='0'&&ch<='9';x=x*10+ch-'0'); 23 return 1; 24 } 25 #undef BUF_SIZE 26 };
fread读入挂:
1 const int BUF=40000000; 2 char Buf[BUF],*buf=Buf; 3 const int OUT=20000000; 4 char Out[OUT],*ou=Out;int Outn[30],Outcnt; 5 inline void write(int x){ 6 if(!x)*ou++=48; 7 else{ 8 for(Outcnt=0;x;x/=10)Outn[++Outcnt]=x%10+48; 9 while(Outcnt)*ou++=Outn[Outcnt--]; 10 } 11 } 12 inline void writell(ll x){ 13 if(!x)*ou++=48; 14 else{ 15 for(Outcnt=0;x;x/=10)Outn[++Outcnt]=x%10+48; 16 while(Outcnt)*ou++=Outn[Outcnt--]; 17 } 18 } 19 inline void writechar(char x){*ou++=x;} 20 inline void writeln(){*ou++='\n';} 21 inline void read(int&a){for(a=0;*buf<48;buf++);while(*buf>47)a=a*10+*buf++-48;} 22 23 24 //这句话放到代码中 25 fread(Buf,1,BUF,stdin); 26 fwrite(Out,1,ou-Out,stdout); 27 //样例 28 #include<bits/stdc++.h> 29 using namespace std; 30 typedef long long ll; 31 const int BUF=40000000; 32 char Buf[BUF],*buf=Buf; 33 const int OUT=20000000; 34 char Out[OUT],*ou=Out;int Outn[30],Outcnt; 35 inline void write(int x){ 36 if(!x)*ou++=48; 37 else{ 38 for(Outcnt=0;x;x/=10)Outn[++Outcnt]=x%10+48; 39 while(Outcnt)*ou++=Outn[Outcnt--]; 40 } 41 } 42 inline void writell(ll x){ 43 if(!x)*ou++=48; 44 else{ 45 for(Outcnt=0;x;x/=10)Outn[++Outcnt]=x%10+48; 46 while(Outcnt)*ou++=Outn[Outcnt--]; 47 } 48 } 49 inline void writechar(char x){*ou++=x;} 50 inline void writeln(){*ou++='\n';} 51 inline void read(int&a){for(a=0;*buf<48;buf++);while(*buf>47)a=a*10+*buf++-48;} 52 53 int main(){ 54 fread(Buf,1,BUF,stdin); 55 int a,b; 56 read(a),read(b); 57 write(a+b); 58 writeln(); 59 fwrite(Out,1,ou-Out,stdout); 60 }
作者:weeping
出处:www.cnblogs.com/weeping/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。