freadIO整理
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 } 14 return *p1++; 15 } 16 inline bool blank(char ch) { 17 return ch==‘ ‘||ch==‘\n‘||ch==‘\r‘||ch==‘\t‘; 18 } 19 inline void read(int &x) { 20 char ch; 21 while(blank(ch=nc())); 22 if(IOerror) return; 23 for(x=ch-‘0‘;(ch=nc())>=‘0‘&&ch<=‘9‘;x=(x<<3)+(x<<1)+ch-‘0‘); 24 } 25 #undef BUF_SIZE 26 }; 27 using namespace fastIO;
时间: 2024-12-12 10:57:17