非负整数的快速输入输出
inline int read() { int x=0; char c; do { c=getchar(); } while(c<'0'||c>'9'); do { x=(x<<3)+(x<<1)+c-'0'; c=getchar(); } while(c>='0'&&c<='9'); return x;}inline void _write(int x) { if(x>9) _write(x/10); putchar(x%10+'0');}inline void write(int x) { _write(x); putchar('\n');}
正负整数的快速输入输出
inline int read() { int x=0; int f=0; char c; do { c=getchar(); if(c=='-') f=1; } while(c<'0'||c>'9'); do { x=(x<<3)+(x<<1)+c-'0'; c=getchar(); } while(c>='0'&&c<='9'); return f?-x:x;}inline void _write(int x) { if(x>9) _write(x/10); putchar(x%10+'0');}inline void write(int x) { if(x<0) { putchar('-'); x=-x; } _write(x); putchar('\n');}
多组输入直到文件结束:
其实要是正常的出题人不会有多余回车在后面的话可以删除后半个EOF检测。bool continue_flag=true;inline int read() { int x=0; char c; do { c=getchar(); if(c==EOF){ exit(0); } } while(c<'0'||c>'9'); do { x=(x<<3)+(x<<1)+c-'0'; c=getchar(); if(c==EOF){ continue_flag=false; return x; } } while(c>='0'&&c<='9'); return x;}