1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> #include <queue> #include <set> #include <vector> using namespace std;
const int INF = ~0u>>1; typedef pair <int,int> P; #define MID(x,y) ((x+y)>>1) #define iabs(x) ((x)>0?(x):-(x)) #define REP(i,a,b) for(int i=(a);i<(b);i++) #define FOR(i,a,b) for(int i=(a);i<=(b);i++) #define pb push_back #define mp make_pair #define print() cout<<"--------"<<endl
const int N = 3e5 + 2; #define mod 1000000007 typedef long long ll;
ll num[N],d[N],e[N],ans[N]; ll power_mod(ll n,ll k){ ll ret = 1; while (k){ if (k & 1) ret = (ret * n) % mod; n = (n*n) % mod; k >>= 1; } return ret; }
ll cal(ll n, ll m){ return (d[n] * e[m] % mod) * e[n-m] % mod; }
int main(){ int n,m,k; d[0] = e[0] = 1; for (int i = 1; i < N; i++){ d[i] = d[i-1] * i % mod; e[i] = power_mod(d[i],mod-2); } while (~scanf("%d%d%d",&n,&m,&k)){ memset(num,0,sizeof(num)); int cnt; for (int i = 0; i < n; i++){ scanf("%d", &cnt); num[cnt]++; } for (int i = m; i >= 1; i--){ int sumd = 0; for (int j = i; j <= m; j += i){ sumd += num[j]; } if (sumd < n-k){ ans[i] = 0; }else{ ans[i] = power_mod(m/i,n-sumd) * power_mod(m/i-1,k-(n-sumd)) % mod; ans[i] = ans[i] * cal(sumd,k-(n-sumd)) %mod; for (int j = 2 * i; j <= m; j += i){ ans[i] = (ans[i] - ans[j] + mod) % mod; } } } for (int i = 1; i < m; i++) cout << ans[i] << ' '; cout << ans[m] << endl; } return 0; }
|