cf C On Number of Decompositions into Multipliers
题意:给你n个数,然后把这个n个数的乘积化成n个数相乘,可以化成多少个。
思路:分解质因数,求出每一个质因子的个数,然后用组合数学中隔板法把这些质因子分成n分,答案就是所有质因子划分成n份的情况的乘积。
#include <cstdio>
#include <cstring>
#include <map>
#include <algorithm>
#define maxn 100100
#define ll long long
using namespace std;
const int mod=; int n;
int a[maxn];
ll c[][]; int main()
{
scanf("%d",&n);
map<int,int>q;
c[][]=;
for(int i=; i<=; i++)
{
c[i][]=;
for(int j=; j<=; j++)
{
c[i][j]=(c[i-][j-]+c[i-][j])%mod;
}
}
for(int i=; i<=n; i++)
{
scanf("%d",&a[i]);
int m=a[i];
for(int i=; i*i<=m; i++)
{
if(m%i==)
{
while(m%i==)
{
q[i]++;
m/=i;
}
}
}
if(m>)
{
q[m]++;
}
}
ll ans=;
map<int,int>::iterator it;
for(it=q.begin(); it!=q.end(); it++)
{
int xx=it->second;
ans*=c[xx+n-][n-];
ans%=mod;
}
printf("%lld\n",ans);
return ;
}
cf C On Number of Decompositions into Multipliers的更多相关文章
- Codeforces396A - On Number of Decompositions into Multipliers
Portal Description 给出\(n(n\leq500)\)个\([1,10^9]\)的数,令\(m=\prod_{i=1}^n a_i\).求有多少个有序排列\(\{a_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个不一样的乘积, ...
- cf C. Prime Number
http://codeforces.com/contest/359/problem/C 先求出分子的公因子,然后根据分子上会除以公因子会长生1,然后记录1的个数就可以. #include <cs ...
- 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 ...
- NGINX(四)配置解析
前言 nginx配置解析是在初始化ngx_cycle_t数据结构时,首先解析core模块,然后core模块依次解析自己的子模块. 配置解析过程 nginx调用ngx_conf_parse函数进行配置文 ...
- windows7 Cygwin 下安装 YouCompleteMe 插件
原创文章,欢迎指正!转载请注明~ 从上周就开始想在cygwin上安装YouCompleteMe插件,按照GITHUB上的官方教程安装,由于自己的理解失误,一直搞不清是按照在windows上安装还是按照 ...
- 基础数位DP小结
HDU 3555 Bomb dp[i][0] 表示含 i 位数的方案总和. sp[i][0] 表示对于位数为len 的 num 在区间[ 10^(i-1) , num/(10^(len-i)) ] 内 ...
随机推荐
- strstr和memcmp函数的实现
#include <stdio.h> #include <stdlib.h> //malloc()函数 typedef unsigned int size_t; size_t ...
- Android中你应该知道的设计模式
建造者模式 建造者模式最明显的标志就是Build类,而在Android中最常用的就是Dialog的构建,Notification的构建也是标准的建造者模式. 建造者模式很好理解,如果一个类的构造需要很 ...
- openmpi+NFS+NIS搭建分布式计算集群
1. 配置防火墙 正确配置防火墙的过滤规则,否则会造成NFS文件系统的挂载失败,NIS账户认证的失败,mpirun远程任务实例投放的失败.一般情况下,计算集群是在内部局域网中使用,所以可 ...
- mailsend - Send mail via SMTP protocol from command line
Introduction mailsend is a simple command line program to send mail via SMTP protocol. I used to sen ...
- 脚本动态监控input
Jquery $('input').bind('input propertychange', function() { //进行相关操作 }); JS if(isIE) { document.getE ...
- 在线预览文件(pdf)
1.flash版(借助flexpaper工具) 可以把pdf文件用pdf2swf工具转换成swf文件.下载地址http://www.swftools.org/download.html 转换代码如下: ...
- vim字符串替换
vi/vim 中可以使用 :s 命令来替换字符串.以前只会使用一种格式来全文替换,今天发现该命令有很多种写法(vi 真是强大啊,还有很多需要学习),记录几种在此,方便以后查询. :s/vivian/s ...
- c# 左连接写法
var itemandformulas = from i in AttendanceItemList join f in AttendanceFormulaList on i.AttendanceCo ...
- 导入sql时报日期类型错误
导入的脚本中有的日期类型数据是:0000-00-00 00:..这种格式的. 需要把这种格式修改一下.有的mysql版本不支持这种0000.设置成当前时间即可
- 【BZOJ1483】【链表启发式合并】梦幻布丁
Description N个布丁摆成一行,进行M次操作.每次将某个颜色的布丁全部变成另一种颜色的,然后再询问当前一共有多少段颜色.例如颜色分别为1,2,2,1的四个布丁一共有3段颜色. Input 第 ...