取模模板
inline ll add(ll a, ll b){return a+b>mod ? a+b-mod : a+b;}
inline ll sub(ll a, ll b){return a-b<0 ? a-b+mod : a-b;}
inline ll mul(ll a, ll b){return a*b%mod;}
inline ll P(ll a,ll b){ll c=1; while{if(b&1) c = mul(c,a); b>>=1; a=mul(a,a);} return c;}快速幂
inline ll P(ll a,ll b){ll c=0; while{if(b&1) c = add(c,a); b>>=1; a=add(a,a);} return c;}快速乘
#a在模mod意义下的逆元
inv[a] = P(a, mod-2);
void prep() {
fac[1] = 1;
for (int i = 2; i < N; i++)
fac[i] = mul(fac[i-1], i);
inv[N-1] = P(fac[N-1], mod-2);
for (int i = N-1; i >= 0; i--)
inv[i] = mul(inv[i+1], i+1);
}
inline ll C(int n, int m){return mul(fac[n], mul(inv[m], inv[n-m]));}
void exgcd(int a, int b, int &x, int &y) {
if(b == 0) {x = 1; y = 0; return;}
exgcd(b, a%b, x, y);
int t = x; x = y; y = t - a/b*y;
}
x,y即为其中一组解