C. On Number of Decompositions into Multipliers
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

You are given an integer m as a product of integers a1, a2, ... an . Your task is to find the number of distinct decompositions of number m into the product of n ordered positive integers.

Decomposition into n products, given in the input, must also be considered in the answer. As the answer can be very large, print it modulo1000000007 (109 + 7).

Input

The first line contains positive integer n (1 ≤ n ≤ 500). The second line contains space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).

Output

In a single line print a single number k — the number of distinct decompositions of number m into n ordered multipliers modulo 1000000007(109 + 7).

input
1
15
output
1

分析:用map存储每个素数的个数接着就是组合公式c(n+k-1,k-1),因为是乘法所以相当于往盒子里面放小球盒子可以为空。因此多出n个盒子

 1 #include<cstring>
 2 #include<cstdio>
 3 #include<algorithm>
 4 #include<map>
 5 typedef long long LL;
 6 using namespace std;
 7 const int MAX =;
 8 const int F = 1e6+;
 9 const int MOD = 1e9+;
 map<int , int > m;
 int a[MAX];
 LL c[][MAX];
 void getp(int n)
 {
     long long i;
     for(i=;(long long)i*i<=n;i++)
     {
         while(n%i==)
         {
             m[i]++;
             n/=i;
         }
     }
     if( n !=  ) m[n]++;
 }
 void init()
 {
     c[][]=;
     for(int i=;i<;i++)
     {
         c[i][i]=c[i][]=;
         for(int j=;j<=min(i,MAX);j++)
         {
             c[i][j]=(c[i-][j]+c[i-][j-])%MOD;
         }
     }
 }
 int main()
 {
     int n;
     LL ans;
     while(scanf("%d",&n)==)
     {
         m.clear(); ans=;
         for(int i=;i<n;i++)
         {
             scanf("%d",&a[i]);
             getp(a[i]);
         }
         init();
         //printf("s");
         for(map<int,int> ::iterator it=m.begin();it!=m.end();it++)
         {
             int k=it->second;
             ans=ans*c[k-+n][n-]%MOD;
         }
         printf("%I64d\n",ans);
     }
     return ;

60 }

Codeforces Round #232 (Div. 2) C的更多相关文章

  1. Codeforces Round #232 (Div. 2) B. On Corruption and Numbers

    题目:http://codeforces.com/contest/397/problem/B 题意:给一个n ,求能不能在[l, r]的区间内的数字相加得到, 数字可多次重复.. 比赛的时候没有想出来 ...

  2. Codeforces Round #232 (Div. 1)

    这次运气比较好,做出两题.本来是冲着第3题可以cdq分治做的,却没想出来,明天再想好了. A. On Number of Decompositions into Multipliers 题意:n个数a ...

  3. Codeforces Round #232 (Div. 1) A 解题报告

    A. On Number of Decompositions into Multipliers 题目连接:http://codeforces.com/contest/396/problem/A 大意: ...

  4. Codeforces Round #232 (Div. 2) D. On Sum of Fractions

    D. On Sum of Fractions Let's assume that v(n) is the largest prime number, that does not exceed n; u ...

  5. Codeforces Round #232 (Div. 2) On Sum of Fractions

    Let's assume that v(n) is the largest prime number, that does not exceed n; u(n) is the smallest pri ...

  6. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  7. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  8. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  9. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

随机推荐

  1. 数据结构之动态顺序表(C实现)

    线性表有2种,分为顺序表和链表. 顺序表: 采用顺序存储方式,在一组地址连续的存储空间上存储数据元素的线性表(长度固定) 链表: 有3种,单链表.双向链表.循环链表(长度不固定) seqList.h ...

  2. 51nod1381 硬币游戏

    1381 硬币游戏 基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题  收藏  关注 有一个简单但是很有趣的游戏.在这个游戏中有一个硬币还有一张桌子,这张桌子上有很多平 ...

  3. pip安装itchat模块成功后annocanda中No module named 'itchat'

    在cmd中pip install itchat 成功后在annocanda中却出现了下面的情况: 经过查找网上各种查询,原来pip默认是把东西安装在系统python环境中,即C:\Python27\L ...

  4. C. Coin Troubles 有依赖的背包 + 完全背包变形

    http://codeforces.com/problemset/problem/283/C 一开始的时候,看着样例不懂,为什么5 * a1 + a3不行呢?也是17啊 原来是,题目要求硬币数目a3 ...

  5. binlog_format不同模式下,对mysqlbinlog恢复的影响

      binlog_format='mixed' (root)[(none)]>use test; Reading table information for completion of tabl ...

  6. 三维卷积:全景图像Spherical CNNs(Code)

    卷积神经网络(CNN)可以很好的处理二维平面图像的问题.然而,对球面图像进行处理需求日益增加.例如,对无人机.机器人.自动驾驶汽车.分子回归问题.全球天气和气候模型的全方位视觉处理问题. 将球形信号的 ...

  7. ThinkPHP---thinkphp实用项

    [一]代码调试 (1)跟踪信息 ①简介:用于展示系统执行的相关状况,类似于快递的物流信息.ThinkPHP中默认关闭.如需使用,则通过配置项SHOW_PAGE_TRACE(显示页面跟踪)来配置. ②位 ...

  8. rename命令中正则表达式的使用

    rename命令用字符串替换的方式批量改变文件名. 格式如下: rename 原字符串  目标字符串  文件(列表) 原字符串:将文件名需要替换的字符串: 目标字符串:将文件名中含有的原字符替换成目标 ...

  9. 若要允许 GET 请求,请将 JsonRequestBehavior 设置为 AllowGet(转载)

    若要允许 GET 请求,请将 JsonRequestBehavior 设置为 AllowGet 若要允许 GET 请求,请将 JsonRequestBehavior 设置为 AllowGet 请将 J ...

  10. gym101343 2017 JUST Programming Contest 2.0

    A.On The Way to Lucky Plaza  (数论)题意:m个店 每个店可以买一个小球的概率为p       求恰好在第m个店买到k个小球的概率 题解:求在前m-1个店买k-1个球再*p ...