Portal

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\)均不相同,所以不会出现重复的计算。即:

\[ans=\prod_{i=1}^t C(n+k_i-1,n-1)$$ 因为$k_i$不超过$nlog_210^9< 15000$,所以可以开数组`C[15000][500]`。
> 时间复杂度$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的更多相关文章

  1. cf C On Number of Decompositions into Multipliers

    题意:给你n个数,然后把这个n个数的乘积化成n个数相乘,可以化成多少个. 思路:分解质因数,求出每一个质因子的个数,然后用组合数学中隔板法把这些质因子分成n分,答案就是所有质因子划分成n份的情况的乘积 ...

  2. 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个不一样的乘积, ...

  3. Codeforces Round #232 (Div. 1)

    这次运气比较好,做出两题.本来是冲着第3题可以cdq分治做的,却没想出来,明天再想好了. A. On Number of Decompositions into Multipliers 题意:n个数a ...

  4. Codeforces Round #232 (Div. 1) A 解题报告

    A. On Number of Decompositions into Multipliers 题目连接:http://codeforces.com/contest/396/problem/A 大意: ...

  5. Codeforces Round #232 (Div. 2) C

    C. On Number of Decompositions into Multipliers time limit per test 1 second memory limit per test 2 ...

  6. Codeforces Round #338 (Div. 2) D. Multipliers 数论

    D. Multipliers 题目连接: http://codeforces.com/contest/615/problem/D Description Ayrat has number n, rep ...

  7. POJ 1221 UNIMODAL PALINDROMIC DECOMPOSITIONS

    总时间限制: 1000ms 内存限制: 65536kB 描述 A sequence of positive integers is Palindromic if it reads the same f ...

  8. codechef Heavy-light Decompositions

    Heavy-light Decompositions Problem Code: HLDOTSSubmit All submissions for this problem are available ...

  9. JavaScript Math和Number对象

    目录 1. Math 对象:数学对象,提供对数据的数学计算.如:获取绝对值.向上取整等.无构造函数,无法被初始化,只提供静态属性和方法. 2. Number 对象 :Js中提供数字的对象.包含整数.浮 ...

随机推荐

  1. NTP服务简介

    定义:NTP全称为Network Time Protocol,即网络时间协议.是用来使计算机时间同步的一种协议.它可以使计算机对服务器或时钟源做同步,可以提供高精度的时间校正(LAN 上与标准时间小于 ...

  2. qconbeijing2018

    https://2018.qconbeijing.com/schedule 会议 · 第一天 (2018/04/20 周五) 时间 日程 上午 主题演讲 大数据下的软件质量建设实践 黄闻欣 出品 人工 ...

  3. P2956 [USACO09OCT]机器人犁田The Robot Plow

    题目描述 Farmer John has purchased a new robotic plow in order to relieve him from the drudgery of plowi ...

  4. spring mvc 通过拦截器记录请求数据和响应数据

    spring mvc 能过拦截器记录请求数据记录有很多种方式,主要有以下三种: 1:过滤器 2:HandlerInterceptor拦截器 3:Aspect接口控制器 但是就我个人所知要记录返回的数据 ...

  5. 2019/05/11 JAVA虚拟机原理堆、栈、方法区概念区别

    Java堆 堆内存用于存放由new创建的对象和数组.在堆中分配的内存,由java虚拟机自动垃圾回收器来管理.在堆中产生了一个数组或者对象后,还可以在栈中定义一个特殊的变量,这个变量的取值等于数组或者对 ...

  6. 11.1Java-接口

    一.接口 interface定义:固定格式 public abstract 返回值类型 方法名字(参数列表);代码: public interface AMyInterface { public ab ...

  7. CF985E Pencils and Boxes

    思路: 先对a数组排序,然后使用动态规划.dp[i]表示前i个能否正确划分.则如果存在dp[j] == 1, i - j + 1 >= k并且a[i] - a[j] < d,那么dp[i] ...

  8. JS进阶-闭包的几种常见形式

    作用域链: //作用域链 var a = 1; function test() { var b =2; return a; } alert(test());//弹出1: alert(b);//不能获取 ...

  9. css3 blur模糊解决ie6-ie9兼容

    css3 blur模糊是css3的新特性,但是不兼容ie6-ie9,以下代码可以解决此问题: filter: progid:DXImageTransform.Microsoft.Blur(Pixel ...

  10. Javaweb学习笔记10—文件上传与下载

    今天来讲javaweb的第10阶段学习.文件的上传与下载,今天主要说的是这个功能的实现,不用说了,听名字就是外行人也知道肯定很重要啦. 老规矩,首先先用一张思维导图来展现今天的博客内容.       ...