常用模板
基础框架
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}
便捷框架
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int inf=0x3f3f3f3f;
const int mod=998244353;
const int N=100005;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
return 0;
}
文件读写
freopen("problem.in","r",stdin);
freopen("problem.out","w",stdout);
cout 格式化
cout<<fixed<<setprecision(6)<<x<<'\n';
cout<<setw(6)<<x<<'\n';
刷新缓冲区
cout<<flush;
fflush(stdout);
cout.flush();
mt19937
random_device rd;
mt19937 gen(rd());
uniform_int_distribution<int> dist(1,100);
int k=dist(gen);
快速幂
ll Pow(ll x,ll y)
{
x%=mod;
ll res=1;
while(y)
{
if(y&1)res=res*x%mod;
x=x*x%mod;
y>>=1;
}
return res;
}
排列组合
ll inv[N],fac[N],jv[N];
void init()
{
fac[0]=jv[0]=1;
for(int i=1;i<N;i++)
{
inv[i]=i==1?1:(mod-mod/i)*inv[mod%i]%mod;
fac[i]=fac[i-1]*i%mod;
jv[i]=jv[i-1]*inv[i]%mod;
}
}