头文件及快读快输

头文件+快速读入+快速输出

头文件一般平时训练可能用的是万能头文件

1
#include<bits/stdc++.h>

万一比赛热身赛时,发现不能使用万能头文件,那就得自备头文件了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include<algorithm>
#include<iostream>
#include<sstream>
#include<cstdlib>
#include<cstring>
#include<cassert>
#include<cstdio>
#include<vector>
#include<string>
#include<queue>
#include<cmath>
#include<stack>
#include<ctime>
#include<map>
#include<set>
#define ll long long
#pragma GCC optimize(2)
using namespace std;
const int maxn=1e6+10;
const int INF=0x3f3f3f;
typedef long long ll;

快速读入

1
2
3
4
5
6
7
8
9
10
11
12
13
14
inline int read()
{
char ch = getchar(); int x = 0, f = 1;
while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
while('0' <= ch && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
return x * f;
}
ll read() //ll配合上面的头文件使用
{
ll x=0,f=1;char ch=getchar();
while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
return f*x;
}

快速输出

1
2
3
4
5
6
int write(int x) 
{
if(x<0){x = -x;putchar('-');}
if (x > 9) write(x / 10);
putchar(x % 10 + '0');
}