40 lines
850 B
Markdown
40 lines
850 B
Markdown
|
|
### 快读快写
|
|||
|
|
```c++
|
|||
|
|
x << 1 == x * 2;
|
|||
|
|
x << 3 == x * 2 * 2 * 2;
|
|||
|
|
```
|
|||
|
|
二者相加也就是 `x * 10`;
|
|||
|
|
|
|||
|
|
(1) 设$ch='3'$ $ASCII= 51 = 00110011(b)$
|
|||
|
|
(2) 字符 $'0'$ $ASCII= 48 = 00110000(b)$
|
|||
|
|
|
|||
|
|
`^`运算规则:同$0$ 异$1$,相同的两个数异或为$0$ 不同的异或为$1$
|
|||
|
|
|
|||
|
|
`ch^48` 相当于 `ch -= '0'` ,得到 $00000011$,即数字$3$
|
|||
|
|
|
|||
|
|
|
|||
|
|
```c++
|
|||
|
|
//快读
|
|||
|
|
inline int read() {
|
|||
|
|
int x = 0, f = 1;
|
|||
|
|
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 ^ 48);
|
|||
|
|
ch = getchar();
|
|||
|
|
}
|
|||
|
|
return x * f;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//快写
|
|||
|
|
inline void write(int x) {
|
|||
|
|
if (x < 0) putchar('-'), x = -x;
|
|||
|
|
if (x > 9) write(x / 10);
|
|||
|
|
putchar(x % 10 + '0');
|
|||
|
|
}
|
|||
|
|
```
|
|||
|
|
|