zoukankan      html  css  js  c++  java
  • cf C On Number of Decompositions into Multipliers

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

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

     1 #include <cstdio>
     2 #include <cstring>
     3 #include <map>
     4 #include <algorithm>
     5 #define maxn 100100
     6 #define ll long long
     7 using namespace std;
     8 const int mod=1000000007;
     9 
    10 int n;
    11 int a[maxn];
    12 ll c[17010][600];
    13 
    14 int main()
    15 {
    16     scanf("%d",&n);
    17     map<int,int>q;
    18     c[0][0]=1;
    19     for(int i=1; i<=15000; i++)
    20     {
    21         c[i][0]=1;
    22         for(int j=1; j<=502; j++)
    23         {
    24             c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
    25         }
    26     }
    27     for(int i=1; i<=n; i++)
    28     {
    29         scanf("%d",&a[i]);
    30         int m=a[i];
    31         for(int i=2; i*i<=m; i++)
    32         {
    33             if(m%i==0)
    34             {
    35                 while(m%i==0)
    36                 {
    37                     q[i]++;
    38                     m/=i;
    39                 }
    40             }
    41         }
    42         if(m>1)
    43         {
    44             q[m]++;
    45         }
    46     }
    47     ll ans=1;
    48     map<int,int>::iterator it;
    49     for(it=q.begin(); it!=q.end(); it++)
    50     {
    51         int xx=it->second;
    52         ans*=c[xx+n-1][n-1];
    53         ans%=mod;
    54     }
    55     printf("%lld
    ",ans);
    56     return 0;
    57 }
    View Code
  • 相关阅读:
    hdp (ambari) 集成hue
    Hive的metastore
    windows 常用cmd命令
    HDFS datanode心跳与运维中的实际案例
    scala drools and map
    hadoop nn 运维一例
    Eclipse 多行注释选择
    JSP SERVLET 基础知识
    记录一次代码错误,elastic search的INDEX需要使用小写字母
    HIVE大数据出现倾斜怎么办
  • 原文地址:https://www.cnblogs.com/fanminghui/p/4257162.html
Copyright © 2011-2022 走看看