快速输入输出
功能
对于大量数据进行快速输入输出。
思路
利用getchar()
代替scanf()
输入整数,利用putchar()
代替printf()
输出整数。
模板
非负整数输入
/**
* @param x: the input number
* @other: x >= 0;
*/
void FR(int& x) {
x = 0;
char ch = getchar();
for (; ch < '0' || ch > '9'; ch = getchar());
for (; ch >= '0' && ch <= '9'; ch = getchar()) {
x = 10*x + ch-'0';
}
}
非负整数输出
char f[100]; // the digits of the output number
/**
* @param x: the output number
* @other: x >= 0;
*/
void FW(const int& x) {
int tmp = x;
int s = 0;
while (tmp > 0) {
f[s++] = tmp%10 + '0';
tmp /= 10;
}
wh