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连试试水的深浅..... ...
随机推荐
- bzoj 1616: [Usaco2008 Mar]Cow Travelling游荡的奶牛【dp】
写了个bfs发现MLE了... 设f[t][i][j]为在t时刻走到(i,j)的方案数,转移和bfs一样 #include<iostream> #include<cstdio> ...
- Java实现短信中提取号码
Description 提取一条短信里所有的电话号码,电话号码之间换行打印,短信的内容由用户输入. Input 第一行有个整数n(1≤n≤1000)表示测试用例的个数.其后的每一行中有一条短信,每一条 ...
- mutiset HDOJ 5349 MZL's simple problem
题目传送门 /* 这题可以用stl的mutiset容器方便求解,我对这东西不熟悉,TLE了几次,最后用读入外挂水过. 题解有O(n)的做法,还以为我是侥幸过的,后来才知道iterator it写在循环 ...
- jQuery图片区域选择控件_imgAreaSelect
软考报名时发现可以进行头像区域裁剪功能,F12了一下,发现使用了imgAreaSelect控件. 控件官网: http://odyniec.net/projects/imgareaselect/ 控件 ...
- python批量下载图片
从数据库拿了一批图片地址,需要一张一张的把图片下载下来,自从有了python,想到能省事就琢磨如何省事. 代码如下: import urllib.requestf=open("E:\999\ ...
- idea安装插件plugin(主要针对网络连接不上的情况)
https://blog.csdn.net/duoduo1636546/article/details/80104711
- leetcode375 Guess Number Higher or Lower II
思路: dp. https://leetcode.com/problems/guess-number-higher-or-lower-ii/discuss/ 实现: class Solution { ...
- Selenium基于Python web自动化基础二 -- 免登录、等待及unittest单元测试框架
一.免登录在进行测试的过程中难免会遇到登录的情况,给测试工作添加了工作量,本文仅提供一些思路供参考解决方式:手动请求中添加cookies.火狐的profile文件记录信息实现.人工介入.万能验证码.去 ...
- Python基础语法(转)
作者:Peter 出处:http://www.cnblogs.com/Peter-Zhang/ Python 基础语法(一) Python的特点 1. 简单 Python是一种代表简单思想的语言. ...
- MERGE INTO USING用法
MERGE INTO [your table-name] [rename your table here] USING ( [write your query here] )[rename your ...