Codeforces-396A - On Number of Decompositions into Multipliers-组合计数
2016-09-09 18:47
417 查看
题目链接
题意:有n个数,他们的乘积是m,将他们分成乘积为m,n个数的有序列,有几种分法。
思路:可以将每个质数的个数求出来,然后分配到n个数中,设质数t有ss个,则放到n个数的种数有Cn−1s+n−1 最后把种数给相乘就好。由于因数比较离散,可以用map来优化一下。
#include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<iostream> #include<map> #define maxn 1111 #define maxm 21111 ///30*500左右 const long long mod=1000000007; using namespace std; map<int,int> gg; long long c[maxm][maxn]; void init(void) { c[0][0]=1; for(int i=1;i<maxm;i++) for(int j=0;j<=i&&j<maxn;j++) { if(j==0||j==i) c[i][j]=1; else c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod; } } void sov(long long x) { ///统计所以质数 for(int j=2;j*j<=x;j++) if(x%j==0) { int tt=0; while(x%j==0) { tt++; x/=j; } gg[j]+=tt; } if(x!=1) { gg[x]+=1; } } int main() { int n; long long xx; init(); while(scanf("%d",&n)!=EOF) { gg.clear(); for(int i=1;i<=n;i++) { scanf("%I64d",&xx); sov(xx); } long long ans=1; for(map<int,int>::iterator it=gg.begin();it!=gg.end();it++) { int tt=(*it).second; ans=(ans*c[tt+n-1][n-1])%mod; } printf("%I64d\n",ans); } return 0; }
相关文章推荐
- C. On Number of Decompositions into Multipliers 组合数学
- cf C On Number of Decompositions into Multipliers
- Codeforces396A - On Number of Decompositions into Multipliers
- CodeForces-245H:Queries for Number of Palindromes(3-14:区间DP||回文串)
- Codeforces 27E Number With The Given Amount Of Divisors (求约数个数为n的最小数)
- CodeForces - 27E Number With The Given Amount Of Divisors (DFS+数学)
- codeforces 660D - Number of Parallelograms
- Codeforces-466C-Number of Ways
- Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.
- CodeForces 396 B.On Sum of Fractions(数论)
- CodeForces - 245H - Queries for Number of Palindromes
- 【Codeforces 805】D. Minimum number of steps
- [Codeforces 724G. Xor-matic Number of the Graph]线性基+计数
- Codeforces 466 C. Number of Ways
- jxl.write.biff.RowsExceededException: The maximum number of rows permitted on a worksheet been excee
- Codeforces Beta Round #27 (Codeforces format, Div. 2) E. Number With The Given Amount Of Divisors 反素数
- Game of Connections -组合数学中的计数问题
- Letter Combinations of a Phone Number (电话号码字母组合) 【leetcode】
- codeforces 785D. Anton and School - 2(组合计数,二项系数计算)
- Codeforces 869C Round #439 Div2 C:排列组合计数