快读快写通过以字符的形式输入和输出,以达到提高程序效率的作用
下面给出快读快些的模板
然后 __int128 类型的变量不能使用标准的 cin, cout, scanf, printf 进行输入输出可以用下面的模板进行输入输出,但要把 int 改为 __int128来输入输出;
应该容易理解吧
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const int MAX_N = 1e3+10;
int read(){
char c = getchar();
int f = 1, x = 0; // f 来表示符号
while(c < '0' || c > '9'){
if(c == '-')
f = -1;
c = getchar();
}
while(c >= '0' && c <= '9'){
//(x << 1) + (x << 3) 等价于 10 * x
// (c ^ '0') 等价于 c - '0'
//位运算效率更高
x = (x << 1) + (x << 3) + (c ^ '0');
c = getchar();
}
return x * f;
}
void print(int x){
if(x < 0){
putchar('-');
x = -x;
}
if(x > 9) print(x / 10);
putchar(x % 10 + '0');
}
void solve(){
}
int main(){
solve();
return 0;
}