1 #include<stdio.h> 2 #include<string.h> 3 typedef long long LL; 4 const int N = 1000001; 5 const int MOD = 1000000007; 6 bool isprime[N];//判断某一个数是不是素数 7 int nprime;//质数个数 8 int prime[N];//质数 9 int C[110][110]; 10 void init() { 11 nprime = 0; 12 memset(isprime, true, sizeof(isprime)); 13 isprime[1] = false; 14 for(int i = 2; i < N; ++i) { 15 if(isprime[i]) { 16 prime[++nprime] = i; 17 for(int j = i + i; j < N; j += i) isprime[j] = false; 18 } 19 } 20 for(int i = 0; i < 110; C[i][0] = 1, C[i++][i] = 1) 21 for(int j = 1; j < i; ++j) C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD; 22 } 23 int count[N]; 24 void divide(int n) { 25 for(int i = 1;i <= nprime && n > 1; ++i) { 26 if(n % prime[i] == 0) { 27 while(n % prime[i]==0) { 28 count[i]++; 29 n /= prime[i]; 30 } 31 } 32 } 33 } 34 int main() { 35 int n; 36 init(); 37 while(scanf("%d", &n) != EOF) { 38 memset(count, 0, sizeof(count)); 39 for(int i = 1; i <= n; ++i) { 40 int b; 41 scanf("%d", &b); 42 divide(b); 43 } 44 LL ans = 0; 45 for(int i = 0; i < n; ++i) { 46 LL temp = C[n][i]; 47 for(int j = 1; j <= nprime; ++j) { 48 if(count[j]) 49 temp = (temp * C[count[j] + n - i - 1][n - i - 1]) % MOD; 50 } 51 if(i & 1) ans = (ans - temp) % MOD; 52 else ans = (ans + temp) % MOD; 53 } 54 printf("%lld\n", (ans + MOD) % MOD); 55 } 56 return 0; 57 }