跳到正文

剪贴板

剪贴板 ix1ljnms

原文
剪贴板信息

剪贴板信息

收录
更新

板板

C++
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define R read<int>()
#define fi first
#define se second
using namespace std;
template <typename T> inline T read(){
	T x=0,fl=1; char c=getchar();
	while(c<'0'||c>'9') (c=='-'?fl=-1:0),c=getchar();
	while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*fl;
}
void print(auto *arr,int n){ for(int i=1;i<=n;i++) cout<<arr[i]<<' '; puts(""); }
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
int main(){
	return 0;
}
C++
ll power(ll x,int y){
	ll res=1;
	while(y){
		if(y&1) res*=x,res%=M;
		x*=x,x%=M,y>>=1;
	}
	return res;
}
void init(int n){
	fc[0]=1;
	for(int i=1;i<=n;i++) fc[i]=fc[i-1]*i%M;
	iv[n]=power(fc[n],M-2);
	for(int i=n-1;~i;i--) iv[i]=iv[i+1]*(i+1)%M;
}
ll C(int x,int y){ return fc[x]*iv[y]%M*iv[x-y]%M; }
struct matrix{
	ll s[K][K];
	friend matrix operator* (const matrix x,const matrix y){
		matrix z;
		for(int i=0;i<k;i++){
			for(int j=0;j<k;j++){
				z.s[i][j]=0;
				for(int o=0;o<k;o++)
					z.s[i][j]+=x.s[i][o]*y.s[o][j]%M;
				z.s[i][j]%=M;
			}
		}
		return z;
	}
};
C++
void write(__int128 x,bool ff=1){
	if(!x){ if(ff) putchar('0'); return; }
	write(x/10,0);
	putchar(x%10+'0');
}
C++
int LCA(int x,int y){
	if(d[x]<d[y]) swap(x,y);
	for(int j=K-1;~j;j--)
		if(d[x]-d[y]>=(1<<j))
			x=f[x][j];
	if(x==y) return x;
	for(int j=K-1;~j;j--)
		if(f[x][j]!=f[y][j])
			x=f[x][j],y=f[y][j];
	return f[x][0];
}
C++
ll gcd(ll x,ll y){
	if(!x) return y;
	if(!y) return x;
	int t=ctz(x|y);
	y>>=ctz(y);
	while(x){
		x>>=ctz(x);
		if(x<y) swap(x,y);
		x-=y;
	}
	return y<<t;
}
C++
template <int M> struct Mint{
	int x;
	Mint(): x(0){}
	Mint(const int a): x(a<0?a+M:a){}
	Mint(const ll a): x(a<0?a+M:a){}
	bool operator== (const Mint a){ return x==a.x; }
	Mint operator= (const int a){ x=a; return *this; }
	Mint operator= (const ll a){ x=a; return *this; }
	Mint operator+= (const Mint a){ return ((x+=a.x)>=M?x-=M:0),*this; }
	Mint operator-= (const Mint a){ return ((x+=M-a.x)>=M?x-=M:0),*this; }
	Mint operator*= (const Mint a){ return x=static_cast<int>(1LL*x*a.x%M),*this; }
	Mint operator+ (const Mint a){ return (*this)+=a; }
	Mint operator- (const Mint a){ return (*this)-=a; }
	Mint operator* (const Mint a){ return (*this)*=a; }
	friend Mint operator^ (const Mint a,const int b){
		Mint res=1,x=a;
		for(int t=b;t;x*=x,t>>=1) if(t&1) res*=x;
		return res;
	}
	Mint inv(){ return (*this)^M-2; }
	Mint operator/= (const Mint a){ return *this*=a.inv(); }
	Mint operator/ (const Mint a){ return (*this)/=a; }
};
#define mint Mint<998244353>
void init(int n){
	fc[0]=1;
	for(int i=1;i<=n;i++) fc[i]=fc[i-1]*i;
	iv[n]=fc[n].inv();
	for(int i=n-1;~i;i--) iv[i]=iv[i+1]*(i+1);
}
mint C(int x,int y){ return fc[x]*iv[y]*iv[x-y]; }
struct matrix{
	mint s[K][K];
	friend matrix operator* (const matrix x,const matrix y){
		matrix z;
		for(int i=0;i<k;i++){
			for(int j=0;j<k;j++){
				z.s[i][j]=0;
				for(int o=0;o<k;o++) z.s[i][j]+=x.s[i][o]*y.s[o][j];
			}
		}
		return z;
	}
};