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连试试水的深浅..... ...
随机推荐
- 10.13NOIP模拟题
/* 容斥原理 考虑到a[i]要么不会太大,要么就对答案贡献很小 dfs即可 */ #include<bits/stdc++.h> #define ll long long #define ...
- 给独立搭建的博客启用https的过程
申请SSL证书 我自己独立搭建的博客部署在阿里云服务器上,因此我就先搜索阿里云启用https的方法,网上有比较详细的讲解,在此提供一个参考网址: https://blog.csdn.net/csluc ...
- Windows Install Twisted 安装Twisted
1.下载twisted exe https://twistedmatrix.com/Releases/Twisted/15.4/ (注意最新版16.x没有适用于windows的exe,只能用旧版) 2 ...
- [转]Windows Azure平台简介(一):定位与产品结构
本文转自:http://blog.csdn.net/azurechina/article/details/5592236 http://blogs.msdn.com/b/azchina/archive ...
- Java多线程——线程之间的协作
Java多线程——线程之间的协作 摘要:本文主要学习多线程之间是如何协作的,以及如何使用wait()方法与notify()/notifyAll()方法. 部分内容来自以下博客: https://www ...
- scala-基础-映射(1)
//映射(1)-构建,获取,更新,迭代,反转,映射(可变与不可变 互换) class Demo1 extends TestCase { //构建与获取 def test_create_^^(){ // ...
- 【C++】Item18. Make interfaces easy to use correctly and hard to use incorrectly
接口容易被正确使用,不易被误用 c++简单工厂模式时,初级实现为ITest* CreateTestOld(), 然后用户负责释放返回的对象.如果忘记释放就会造成memory leak,所以在设计工厂接 ...
- opencv 检测图片中圆形物体(解决乱线问题)
2018-03-0418:03:12 整体代码如下: def detect_circle_demo (image): # 降噪处理 dst = cv.pyrMeanShiftFiltering(ima ...
- Android基础夯实--重温动画(一)之Tween Animation
心灵鸡汤:真正成功的人生,不在于成就的大小,而在于你是否努力地去实现自我,喊出自己的声音,走出属于自己的道路. 摘要 不积跬步,无以至千里:不积小流,无以成江海.学习任何东西我们都离不开扎实的基础知识 ...
- 廖雪峰 Git教程学习笔记 原文 http://www.liaoxuefeng.com/
一 .集中式与分布式 先说集中式版本控制系统,版本库是集中存放在中央服务器的,而干活的时候,用的都是自己的电脑,所以要先从中央服务器取得最新的版本,然后开始干活,干完活了,再把自己的活推 ...