cf C On Number of Decompositions into Multipliers

题意:给你n个数,然后把这个n个数的乘积化成n个数相乘,可以化成多少个。

思路:分解质因数,求出每一个质因子的个数,然后用组合数学中隔板法把这些质因子分成n分,答案就是所有质因子划分成n份的情况的乘积。

 #include <cstdio>
#include <cstring>
#include <map>
#include <algorithm>
#define maxn 100100
#define ll long long
using namespace std;
const int mod=; int n;
int a[maxn];
ll c[][]; int main()
{
scanf("%d",&n);
map<int,int>q;
c[][]=;
for(int i=; i<=; i++)
{
c[i][]=;
for(int j=; j<=; j++)
{
c[i][j]=(c[i-][j-]+c[i-][j])%mod;
}
}
for(int i=; i<=n; i++)
{
scanf("%d",&a[i]);
int m=a[i];
for(int i=; i*i<=m; i++)
{
if(m%i==)
{
while(m%i==)
{
q[i]++;
m/=i;
}
}
}
if(m>)
{
q[m]++;
}
}
ll ans=;
map<int,int>::iterator it;
for(it=q.begin(); it!=q.end(); it++)
{
int xx=it->second;
ans*=c[xx+n-][n-];
ans%=mod;
}
printf("%lld\n",ans);
return ;
}
上一篇:Wormholes(SPFA+Bellman)


下一篇:spring 之 注入之 by name or by type, or both ?