Description
给出一个正整数
m
,问满足
Input
两个正整数 n,m(1≤n≤500,1≤m≤109)
Output
输出满足条件的序列个数,结果模 109+7
Sample Input
1
15
Sample Output
1
Solution
把
n
质因数分解
Code
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<ctime>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int INF=0x3f3f3f3f,maxn=505;
#define mod 1000000007
int inv[maxn],n;
map<int,int>M;
map<int,int>::iterator it;
void init(int n=500)
{
inv[1]=1;
for(int i=2;i<=n;i++)inv[i]=mod-(ll)(mod/i)*inv[mod%i]%mod;
}
int C(int n,int m)
{
int ans=1;
for(int i=1;i<=m;i++)ans=(ll)ans*(n-m+i)%mod*inv[i]%mod;
return ans;
}
void Solve(int x)
{
for(int i=2;i*i<=x;i++)
while(x%i==0)
x/=i,M[i]++;
if(x>1)M[x]++;
}
int main()
{
init();
while(~scanf("%d",&n))
{
M.clear();
for(int i=1;i<=n;i++)
{
int a;
scanf("%d",&a);
Solve(a);
}
int ans=1;
for(it=M.begin();it!=M.end();it++)
ans=(ll)ans*C(n+it->second-1,n-1)%mod;
printf("%d\n",ans);
}
return 0;
}