标签:++ sed color fast code fwrite out show ast
不考虑内存浪费的fastIO
1 #include<bits/stdc++.h> 2 using namespace std; 3 namespace IO 4 { 5 const int len=1<<25; 6 bool flag; 7 char ch,ibuf[len],wbuf[len]; 8 int il=0,wl=0,g,G[55]; 9 void in(){int x=fread(ibuf,1,len,stdin);} 10 inline void out(){int x=fwrite(wbuf,1,wl,stdout);} 11 inline void gc(char&c){c=ibuf[il++];} 12 template<typename T>void read(T&x) 13 { 14 flag=0;gc(ch); 15 if(ch==‘-‘)flag=1; 16 while(!isdigit(ch)){if(ch==‘-‘)flag=1;gc(ch);} 17 x=ch-‘0‘;gc(ch); 18 while(isdigit(ch)){x=x*10+ch-‘0‘;gc(ch);} 19 x=flag?-x:x; 20 } 21 template<typename T>void write(T x) 22 { 23 if(x<0)wbuf[wl++]=‘-‘,x=-x; 24 g=0; 25 do{G[++g]=x%10;x/=10;}while(x); 26 for(int i=g;i>=1;--i)wbuf[wl++]=‘0‘+G[i]; 27 wbuf[wl++]=‘\n‘; 28 } 29 } 30 int main() 31 { 32 ios::sync_with_stdio(false); 33 IO::in(); 34 IO::out(); 35 return 0; 36 }
若总共需要读入和输出len个字符,需占用len/1048576*2 Mb的内存。
标签:++ sed color fast code fwrite out show ast
原文地址:https://www.cnblogs.com/GreenDuck/p/13193785.html