令
f
i
f_i
fi表示
i
∣
g
c
d
i|gcd
i∣gcd的方案数
a
n
s
i
ans_i
ansi表示
g
c
d
=
i
gcd=i
gcd=i的方案数
那么有
f
i
=
∑
i
∣
d
a
n
s
d
f_i=\sum_{i|d}ans_d
fi=∑i∣dansd
搞一个后缀和的莫比乌斯反演可以得到
a
n
s
i
=
∑
i
∣
d
μ
(
d
i
)
∗
f
d
ans_i=\sum_{i|d}\mu(\frac d i)*f_d
ansi=∑i∣dμ(id)∗fd
考虑怎么求
f
i
f_i
fi
显然所有数只能取
i
i
i的倍数
又要求
k
k
k个位置和
A
A
A不同
设
c
n
t
i
cnt_i
cnti为为
i
i
i的倍数的
A
A
A的数量
则
f
i
=
(
m
/
i
)
n
−
c
n
t
∗
(
c
n
t
n
−
k
)
∗
(
m
/
i
−
1
)
c
n
t
−
(
n
−
k
)
f_i=(m/i)^{n-cnt}*{cnt\choose n-k}*(m/i-1)^{cnt-(n-k)}
fi=(m/i)n−cnt∗(n−kcnt)∗(m/i−1)cnt−(n−k)
然后就完了
#include<bits/stdc++.h>
using namespace std;
const int RLEN=1<<20|1;
inline char gc(){
static char ibuf[RLEN],*ib,*ob;
(ob==ib)&&(ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
return (ob==ib)?EOF:*ib++;
}
#define gc getchar
inline int read(){
char ch=gc();
int res=0,f=1;
while(!isdigit(ch))f^=ch=='-',ch=gc();
while(isdigit(ch))res=(res+(res<<2)<<1)+(ch^48),ch=gc();
return f?res:-res;
}
#define ll long long
#define re register
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define cs const
#define poly vector<int>
#define db double
#define bg begin
cs int mod=1e9+7,G=3;
inline int add(int a,int b){return a+b>=mod?a+b-mod:a+b;}
inline void Add(int &a,int b){a=add(a,b);}
inline int dec(int a,int b){return a>=b?a-b:a-b+mod;}
inline void Dec(int &a,int b){a=dec(a,b);}
inline int mul(int a,int b){return 1ll*a*b>=mod?1ll*a*b%mod:a*b;}
inline void Mul(int &a,int b){a=mul(a,b);}
inline int ksm(int a,int b,int res=1){
if(b<0)return 0;
for(;b;b>>=1,a=mul(a,a))(b&1)?(res=mul(res,a)):0;return res;
}
inline void chemx(int &a,int b){a<b?a=b:0;}
inline void chemn(int &a,int b){a>b?a=b:0;}
cs int N=300005;
int pr[N],tot,mu[N],f[N],ans[N],cnt[N],buc[N];
bitset<N> vis;
int n,m,k;
int fac[N],ifac[N];
inline int C(int n,int m){
return n<m?0:mul(fac[n],mul(ifac[m],ifac[n-m]));
}
inline void init(cs int len=N-5){
mu[1]=fac[0]=ifac[0]=1;
for(int i=1;i<=len;i++)fac[i]=mul(fac[i-1],i);
ifac[len]=ksm(fac[len],mod-2);
for(int i=len-1;i;i--)ifac[i]=mul(ifac[i+1],i+1);
for(int i=2;i<=len;i++){
if(!vis[i])pr[++tot]=i,mu[i]=-1;
for(int j=1;j<=tot&&i*pr[j]<=len;j++){
vis[i*pr[j]]=1;
if(i%pr[j]==0)break;
mu[i*pr[j]]=-mu[i];
}
}
for(int i=2;i<=len;i++)mu[i]=(mu[i]+mod)%mod;
}
int main(){
init();
n=read(),m=read(),k=read();
for(int i=1;i<=n;i++)buc[read()]++;
for(int i=1;i<=m;i++)
for(int j=i;j<=m;j+=i)
cnt[i]+=buc[j];
for(int i=1;i<=m;i++)
f[i]=mul(ksm(m/i,n-cnt[i]),mul(C(cnt[i],n-k),ksm(m/i-1,cnt[i]-n+k)));
for(int i=1;i<=m;i++)
for(int j=1;j*i<=m;j++)
Add(ans[i],mul(mu[j],f[i*j]));
for(int i=1;i<=m;i++)cout<<ans[i]<<" ";
}