(模板)读入优化+输出优化

树下

2018-08-27 15:45:26

Personal

#### 读入优化 ``` template <class sjy> inline void read(sjy &x){ sjy f=1;x=0;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();} x*=f; } ``` #### 输出优化 ``` template<class sjy> inline void write(sjy x){ if(x<0){putchar('-');x=-x;} if(x>9)print(x/10); putchar(x%10+'0'); } ```