Codeforces Round #232 (Div. 2) C
1 second
256 megabytes
standard input
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).
The first line contains positive integer n (1 ≤ n ≤ 500). The second line contains space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).
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).
1
15
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的更多相关文章
- Codeforces Round #232 (Div. 2) B. On Corruption and Numbers
题目:http://codeforces.com/contest/397/problem/B 题意:给一个n ,求能不能在[l, r]的区间内的数字相加得到, 数字可多次重复.. 比赛的时候没有想出来 ...
- Codeforces Round #232 (Div. 1)
这次运气比较好,做出两题.本来是冲着第3题可以cdq分治做的,却没想出来,明天再想好了. A. On Number of Decompositions into Multipliers 题意:n个数a ...
- Codeforces Round #232 (Div. 1) A 解题报告
A. On Number of Decompositions into Multipliers 题目连接:http://codeforces.com/contest/396/problem/A 大意: ...
- 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 ...
- 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 ...
- 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 ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
随机推荐
- vue学习笔记(1)
1.检测变化 <ul> <li v-for="item in list">{{item}}</li> </ul> <scrip ...
- 台哥原创:java 连连看源码
2010年,迷上了玩连连看 随手就做了这个,正好手头有这些图片素材 游戏启动时,界面先铺上了一层透明幕布,然后这些兵器图片交替从上到下,从左到右出现.. 鼠标停在兵器格子上时,所在格子会有红色 ...
- 洛谷2019 3月月赛 T2
题干 洛谷同款 T2?(看似比T1简单些) 二维前缀和嘛?[多简单 我天天拿二维前缀和水DP] 这是前缀和的预处理 2333 处理出来所有的情况 某个地方要加上mod再%mod 如果没有这一步 那么 ...
- 在dataGridView空间中添加数据
//查询信息sql语句 string sql = "select studentName,addres from student"; SqlDataAdapter adapter ...
- ubuntu下删除和新建用户(并有su权限)
http://blog.csdn.net/speedme/article/details/8206144ubuntu下删除和新建用户(并有su权限) 如何创建ubuntu新用户?输入:sudo add ...
- 图片选择器ImageEditContainer
1. 简介 本次demo中一共封装了两个组件:ImageEditButton 和 ImageEditContainer.其中ImageEditContainer 是在 ImageEditButton, ...
- Python自动监控错误日志
平时在查看日志的时候打开满屏的日志,看上去有点凌乱.于是写个Python脚本过滤出想要看的错误的日志.直接上脚本 脚本示例 def read_log(logname,keyword): tell = ...
- 求助:可以使用任何编程工具做成一个控件或组件,使得在VB中能调用并得到摄像头的参数及图片。
请看下网址上的这个问题,看是否有解决的方式http://www.educity.cn/wenda/338634.html
- JDBC性能优化
一.使用PreparedStatement的Batch功能 参见本人一下文章:http://blog.csdn.net/lmb55/article/details/50631062 二.选择合适的光标 ...
- JavaScript 单例,Hash,抛异常
1. 单例 ECMA 5 版 记得以前写过几种单例实现,找不到了... function Singleton() { if (this.constructor.instance) { return t ...