# Tag-NTT

Icontofig 's Blog // 我们的征程是星辰大海！Away From OI，Come to ICPC（查看友链请点About Me）

## 题解

So……这时候我们就用到容斥原理了。假设$an{s}_{i}$$ans_i$为恰好i种颜色都恰好出现k次,由容斥原理有：
$an{s}_{i}=\sum _{j=i}^{min\left(m,n/S\right)}{\left(-1\right)}^{j-i}\ast {C}_{j}^{i}\ast {f}_{j}\ast j！$$ans_i = \sum_{j=i}^{min(m,$

#include <bits/stdc++.h>
using namespace std;
int n,m,s;
const int maxm = 1e5+5;
const int maxn = 1e7+5;
typedef long long ll;
const ll mod = 1004535809;
ll fac[maxn],inv[maxn],w[maxm],f[maxm<<2],finv[maxn];
ll b[maxm<<2];
int rev[maxm<<2];
void init(int x){
fac[0] = fac[1] = inv[0] = inv[1] = finv[0] = finv[1] = 1ll;
for(int i = 2;i <= x;++i){
fac[i] = fac[i-1] * i % mod;
inv[i] = (mod - mod / i) * inv[mod % i] % mod;
finv[i] = finv[i-1] * inv[i] % mod;
}
return;
}
ll quick_pow(ll a,ll b,ll mod){
ll ret = 1;
while(b){
if(b & 1)
ret = (ret * a) % mod;
a = (a * a) % mod;
b >>= 1;
}
return ret;
}
ll g;
int len,lg;
void NTT_init(int k){
len = 1;lg = 0;
for(len = 1;len < k;len <<= 1,lg++);
for(int i = 0;i < len;++i)
rev[i] = (rev[i>>1]>>1) | ((i & 1) << (lg - 1));
}
void NTT(ll *a,int len,int f){
for(int i = 0;i < len;++i){
if(i < rev[i])
swap(a[i],a[rev[i

## 代码

#include <bits/stdc++.h>
using namespace std;
const int maxm = 16005;
typedef long long ll;
const ll gf = 3;
int n,m,x,s;
ll tmp;
int sq;
const ll mod = 1004535809;
ll f
Title - Artist
0:00