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. vue学习笔记(1)

    1.检测变化 <ul> <li v-for="item in list">{{item}}</li> </ul> <scrip ...

  2. Spring中bean的作用域与生命周期

    在 Spring 中,那些组成应用程序的主体及由 Spring IOC 容器所管理的对象,被称之为 bean.简单地讲,bean 就是由 IOC 容器初始化.装配及管理的对象,除此之外,bean 就与 ...

  3. 乐搏讲自动化测试-Python语言常识及前景(3)

    相信小伙伴们都知道,随着软件测试行业的发展和进步自动化测试已经成为必然.在竞争日益激烈的市场环境中也是你升职加薪的利器. 所以,小编决定从今天起!将要系统.连续.高质量的持续更新「整套自动化测试」文章 ...

  4. [C++ STL] map使用详解

    一.set介绍: Map由红黑树实现,其元素都是"键值/实值"所形成的一个对组(key/value pairs).每个元素有一个键,是排序准则的基础.每一个键只能出现一次,不允许重 ...

  5. redis 配置多个ip 解决方案

    因为在 redis 中bind 指定的ip 其实为同一网段或localhost 监听ip,在这里配置 内网其他网段或者外网多个ip 后  重启 redis 是不会成功的, 这边建议使用 折中方案,开通 ...

  6. SQL传入时间获取到时间的周一和周日

    declare @time datetime declare @timeMonday datetime set @time='2013-11-07' ) ,@time) select @timeMon ...

  7. Python学习日记之字典深复制与浅复制

    Python中通过copy模块有两种复制(深复制与浅复制) copy 浅复制 复制时只会复制父对象,而不会复制对象的内部的子对象. deepcopy 深复制 复制对象及其子对象 因此,复制后对原dic ...

  8. Selenium Grid操作使用指南

    一.实现串行多浏览器执行脚本1.启动selenium-server-standalonejava -jar selenium-server-standalone-2.44.0.jar2.脚本代码 fr ...

  9. json-server模拟REST API

    介绍 可以开启一个服务前端使用 安装 npm i json-server -g 使用 $ json-server db.json -p 3000 // 在文件目录下执行上述命令,开放一个端口3000的 ...

  10. SQL SERVER 2008 在某表中新增一列时失败

    背景:新增列语句如:“alter table 表名 add 列名 float default 0 with values”(用VS2010做网站,这句话是在C#代码里执行的) 报错提示: 警告: 已经 ...