输入优化和输出优化
1 inline int read() 2 { 3 int x=0,w=1;char ch=0; 4 while(!isdigit(ch)){if(ch=='-') w=-1;ch=getchar();} 5 while(isdigit(ch)) x=(x<<3)+(x<<1)+ch-'0',ch=getchar(); 6 return x*w; 7 } 8 int buf[30]; 9 void write(int x) 10 { 11 if(x<0) putchar('-'),x=-x; 12 buf[0]=0; 13 while(x) buf[++buf[0]]=x%10,x/=10; 14 if(!buf[0]) buf[0]=1,buf[1]=0; 15 while(buf[0]) putchar('0'+buf[buf[0]--]); 16 }