Codeforces396A - On Number of Decompositions into Multipliers
Description
给出\(n(n\leq500)\)个\([1,10^9]\)的数,令\(m=\prod_{i=1}^n a_i\)。求有多少个有序排列\(\{a_n\}\),使得\(\prod_{i=1}^n a_i=m\)。答案\(mod \ 10^9+7\);两个有序排列不同当且仅当\(\exists i,a_i \neq b_i\)。
Solution
将\(m\)分解质因数,即\(m=\prod_{i=1}^t p_i^{k_i}\)。
将\(m\)分配到\(n\)个数上,相当于依次将\(k_i\)个\(p_i\)分配到\(n\)个数上。因为\(p_i\)均不相同,所以不会出现重复的计算。即:
> 时间复杂度$O(?)$,分解质因数复杂度怎么算呀...
##Code
```
//On Number of Decompositions into Multipliers
#include <cstdio>
#include <cstring>
#include <map>
using namespace std;
typedef long long lint;
int const N0=1e5+10;
lint const H=1e9+7;
map<int,int>::iterator it;
map<int,int> cnt;
bool isP[N0]; int cntP,P[N0];
lint C[15000][510];
void init()
{
memset(isP,true,sizeof isP);
for(int i=2;i<=1e5;i++)
{
if(isP[i]) P[++cntP]=i;
for(int j=1;j<=cntP;j++)
{
if(i*P[j]>1e5) break;
isP[i*P[j]]=false;
if(i%P[j]==0) break;
}
}
for(int i=0;i<15e3;i++) C[i][0]=1;
for(int i=1;i<15e3;i++)
for(int j=1;j<=i&&j<=500;j++) C[i][j]=(C[i-1][j-1]+C[i-1][j])%H;
}
int n;
int main()
{
init();
scanf("%d",&n);
for(int owo=1;owo<=n;owo++)
{
int x; scanf("%d",&x);
for(int i=1;i<=cntP;i++)
while(x%P[i]==0) cnt[P[i]]++,x/=P[i];
if(x!=1) cnt[x]++;
}
lint ans=1;
for(it=cnt.begin();it!=cnt.end();it++) ans*=C[it->second+n-1][n-1],ans%=H;
printf("%lld\n",ans);
return 0;
}
```
##P.S.
我VisJiao就是打死,也不吃STL一口饭!
...真香\]
Codeforces396A - On Number of Decompositions into Multipliers的更多相关文章
- cf C On Number of Decompositions into Multipliers
题意:给你n个数,然后把这个n个数的乘积化成n个数相乘,可以化成多少个. 思路:分解质因数,求出每一个质因子的个数,然后用组合数学中隔板法把这些质因子分成n分,答案就是所有质因子划分成n份的情况的乘积 ...
- C. On Number of Decompositions into Multipliers 组合数学
http://codeforces.com/contest/397/problem/C 给出n个数字,m = a[1] * a[2] * a[3] ... * a[n] 要求把m分成n个不一样的乘积, ...
- 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) C
C. On Number of Decompositions into Multipliers time limit per test 1 second memory limit per test 2 ...
- Codeforces Round #338 (Div. 2) D. Multipliers 数论
D. Multipliers 题目连接: http://codeforces.com/contest/615/problem/D Description Ayrat has number n, rep ...
- POJ 1221 UNIMODAL PALINDROMIC DECOMPOSITIONS
总时间限制: 1000ms 内存限制: 65536kB 描述 A sequence of positive integers is Palindromic if it reads the same f ...
- codechef Heavy-light Decompositions
Heavy-light Decompositions Problem Code: HLDOTSSubmit All submissions for this problem are available ...
- JavaScript Math和Number对象
目录 1. Math 对象:数学对象,提供对数据的数学计算.如:获取绝对值.向上取整等.无构造函数,无法被初始化,只提供静态属性和方法. 2. Number 对象 :Js中提供数字的对象.包含整数.浮 ...
随机推荐
- A8ERP管理系统(采购单管理)
花了一个星期的时间终于把采购模块完成了. 最近新开发的采购单管理,供大家参考学习,软件一步一步来.
- Elasticsearch (1) - 索引库 文档 分词
创建索引库 ES的索引库是一个逻辑概念,它包括了分词列表及文档列表,同一个索引库中存储了相同类型的文档.它就相当于MySQL中的表,或相当于Mongodb中的集合. 关于索引这个语: 索引(名词):E ...
- logging模块基础
很多程序都有记录日志的需求,日志不仅可以保存访问记录,也可以有错误,警告等信息输出. python的logging模块提供了标准的日志接口,可以通过logging存储各种格式的日志.logging模块 ...
- 2018微软实习笔试一道dp题目总结
题意大概是说在一维数轴上起点和终点的距离是d,现在我们要从起点走到终点.每走一个单位长度消耗一个单位能量,初始时有K单位能量.同时在起点和终点之间分布一些加油站a1,a2,...an,给你加油站数量. ...
- STM32&AT指令NBIOT模组
#include "nbiot.h" #include "string.h" #include "stdlib.h" #include &q ...
- Android利用融云做异地登录提醒
在RongCloudEvent下找到onChanged方法 @Override public void onChanged(ConnectionStatus connectionStatus) { s ...
- 基于VueJS的render渲染函数结合自定义组件打造一款非常强大的IView 的Table
基于VueJS的render渲染函数结合自定义组件打造一款非常强大的IView 的Table https://segmentfault.com/a/1190000015970367
- Perl: hash散列转换为Json报错集, perl.c,v $$Revision: 4.0.1.8 $$Date: 1993/02/05 19:39:30 $
bash-2.03$ ./u_json.pl Can't locate object method "encode" via package "JSON" at ...
- 树莓派搭建Seafile个人网盘
步骤一.安装Seafile依赖包 yum install python-setuptools python-ldap python-memcached MySQL-python mariadb mar ...
- python基础(一)—— 核心数据类型
Hello World程序 [root@mysql ~]# python3 Python 3.6.5 (default, Jul 8 2018, 11:41:23) [GCC 4.4.7 20120 ...