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中提供数字的对象.包含整数.浮 ...
随机推荐
- P1847 轰炸II
题目背景 本题为轰炸数据加强版 题目描述 一个城市遭到了M次轰炸,每次都炸了一个每条边都与边界平行的矩形 在轰炸后,有N个关键点,指挥官想知道,它们有没有受到过轰炸,如果有,被炸了几次,最后一次是第几 ...
- oracle常用数据类型&约束条件(及案例)
一.数据类型 数据类型 说明 数字 number [小数,整数] number(5,3)表示总共5个数字,小数点后3个,最大值99.999 number(5) 表示整数 最大值99999 字符 ...
- 前端之HTML样式
<!doctype html> h5的文档声明 <html> 网页的根标签(根元素 html)--所有的代码都放置在此内 <head> <meta chars ...
- day02 -操作系统及python入门
操作系统 1.什么是操作系统? 操作系统位于计算机硬件和应用软件之间. 是一个协调.控制.管理计算机硬件资源和软件资源的控制程序. 2.为何要有操作系统? ①·控制硬件 ②·把对硬件的复杂的操作封装成 ...
- codeforces415D. Glad to see you!(交互)
题意 交互题. 有$k$个值域为$[1, n]$的数. 请在不超过$60$次询问内找出其中的两个数. 每次询问形式为1 x y 交互库会返回$|x - a| <= |y - b| ? " ...
- 简单修改BOOK主题样式
body{ font-size: 13px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; margin: 0px; word ...
- 原创:四种Linux系统开机启动项优命令超给力超详细详解
老葵花哥哥又开课了 接下来是你们的齐天大圣孙悟空给你们带来的详细版Linux系统开机启动优化四种命令 第一种方法是很正常的 第二种有点难理解 第三种来自我的一个奇思妙想 本文档秉承 不要钱也不要臀部的 ...
- Java数据结构和算法(三)--三大排序--冒泡、选择、插入排序
三大排序在我们刚开始学习编程的时候就接触过,也是刚开始工作笔试会遇到的,后续也会学习希尔.快速排序,这里顺便复习一下 冒泡排序: 步骤: 1.从首位开始,比较首位和右边的索引 2.如果当前位置比右边的 ...
- Linux的Network Tunnel技术
Linux的Network Tunnel技术 概要 Linux上可以使用ip tunnel命令创建多种类型的tunnel. 在 man ip-tunnel 中可以得知以下几种类型的tunnel: MO ...
- linux 安装nginx 集成emq
1:下载nginx-1.12.2.tar.gz http://nginx.org/en/download.html 2:解压 tar -zxvf nginx-1.12.2.tar.gz 3:进行co ...