Given a number sequence b 1,b 2…b n.
Please count how many number sequences a 1,a2,...,a n satisfy the condition that a 1*a 2*...*an=b 1*b 2*…*b n (a i>1).
Input
The input consists of multiple test cases.
For each test case, the first line contains an integer n(1<=n<=20). The second line contains n integers which indicate b 1, b 2,...,b n(1<bi<=1000000, b 1*b 2*…*b n<=10 25).
Output
For each test case, please print the answer module 1e9 + 7.
Sample Input
2 3 4
Sample Output
4
Hint
For the sample input, P=3*4=12. Here are the number sequences that satisfy the condition: 2 6 3 4 4 3 6 2
#include<iostream>>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define maxn 1005
#define ll long long
const ll mod=1e9+7;
#define maxm 1000005
using namespace std;
int p[maxm];
int a[maxm];
ll c[maxn][maxn];
int vis[maxm];
void init()
{
int i,j;
for(i=0;i<maxn;i++)
{
c[i][i]=c[i][0]=1;
for(j=1;j<i;j++)
c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
}
}
ll getnum(int m,int n)
{
return c[m+n-1][n-1];
}
ll solve(int cnt,int n)
{
int i,j;
ll ans=1;
for(i=0;i<=cnt;i++)
ans=(ans*getnum(a[i],n))%mod;
for(i=1;i<n;i++)
{
ll temp=c[n][i];
for(j=0;j<=cnt;j++)
temp=(temp*getnum(a[j],n-i))%mod;
if(i&1)
ans=(ans-temp+mod)%mod;
else
ans=(ans%mod+temp%mod)%mod;
}
return ans;
}
int main()
{
init();
int n;
while(~scanf("%d",&n))
{
int t,i,j;
int cnt=0;
for( i=0;i<n;i++)
{
scanf("%d",&t);
for( j=2;j*j<=t;j++)
{
while(t%j==0)
{
p[cnt++]=j;
t/=j;
}
}
if(t>1)
p[cnt++]=t;
}
sort(p,p+cnt);
a[0]=1;
i=0;
for(j=1;j<cnt;j++)
{
if(p[j]==p[j-1])
a[i]++;
else
a[++i]=1;
}
cnt=i;
printf("%lld\n",solve(cnt,n));
}
return 0;
}