C. On Number of Decompositions into Multipliers -- Codeforces
C. On Number of Decompositions into Multipliers
https://codeforces.com/problemset/problem/397/C
思路
Code
https://codeforces.com/contest/397/submission/185147057
#include<bits/stdc++.h> using namespace std; #define int long long const int mod=1e9+7; const int MAXV=20000; int inv[MAXV+10],jc[MAXV+10],invjc[MAXV+10]; int ksm(int a,int b,int res=1) { for(;b;a=a*a%mod,b>>=1) if(b&1) res=res*a%mod; return res; } void init() { jc[0]=1; for(int i=1;i<=MAXV;i++) jc[i]=jc[i-1]*i%mod; invjc[MAXV]=ksm(jc[MAXV],mod-2); for(int i=MAXV;i>0;i--) invjc[i-1]=invjc[i]*i%mod; for(int i=1;i<=MAXV;i++) inv[i]=jc[i-1]*invjc[i]%mod; } int C(int x,int y) { return jc[x]*invjc[y]%mod*invjc[x-y]%mod; } signed main() { init(); int n; cin>>n; map<int,int> mp; for(int i=1;i<=n;i++) { int x; cin>>x; for(int j=2;j*j<=x;j++) while(x%j==0) x/=j,mp[j]++; if(x>1) mp[x]++; } int ans=1; for(auto tmp:mp) (ans*=C(tmp.second+n-1,n-1))%=mod; cout<<ans<<endl; return 0; }
组合数解释
https://www.cnblogs.com/ke-xin/p/13532206.html
![]()
C
出处:http://www.cnblogs.com/lightsong/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。