1.快读优化(在1e3以上的数据量比cin快20%)
template<typename T>
inline void read(T &x)
{
x=0;
int f=1;
char c=getchar(); //c++17中删除了register
while(c<'0'||c>'9'){
if(c=='-') f=-1;
c=getchar();
}
while(c>='0'&&c<='9'){
x=(x<<3)+(x<<1)+c-'0';
c=getchar();
}
x*=f;
}
template<typename T>
inline void write(T x)
{
if(x<0){
putchar('-');
x=~x+1;
}
if(x>=10) write(x/10);
putchar(x%10+'0');
}
2.内联函数(inline)
3.别用万用头
4.尽量用位运算
得益于计算机的底层电路设计,位运算的速度都很快