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)) ] 内 ...
随机推荐
- richTextBox1 转到行号
private void button2_Click(object sender, EventArgs e) { Win32CommonDialog.frm_GOTO frm = new ...
- wdlinux 编译pdo_mysql
由于项目需要用到pdo 链接数据库 wdlinux在centos6.4下 没有pdomysql模块 ,所以重新编译 有的系统无法使用pdo_mysql 1 重新编译mysql http://www.w ...
- [每日一题] 11gOCP 1z0-052 :2013-09-1 RMAN-- repair failure........................................A20
转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/10859315 正确答案:D 一.模拟上题的错误: 1.删除4号文件 [oracle@myd ...
- [Javascript] Creating an Immutable Object Graph with Immutable.js Map()
Learn how to create an Immutable.Map() through plain Javascript object construction and also via arr ...
- android 03 TableLayout
MainActivity.java(默认的,什么都没有) package com.sxt.day02_02; import android.os.Bundle; import android.app. ...
- 用 Qt 中的 QDomDocument类 处理 XML 文件(下)
QDomDocument doc; 1).创建根节点:QDomElement root = doc.documentElement("rootName " ); 2).创建元素 ...
- JAVA大集合数据分批次进行切割处理
今天遇到一个大集合里面的数据删除问题, 因为是一个大集合,如果同时传递到数据库,那么就会造成数据库压力 所以分批次的进行批量操作 其实 也可以采用多线程来处理或者多批次加多线程来处理都是可以的 下面的 ...
- Five ways to maximize Java NIO and NIO.2--reference
Java NIO -- the New Input/Output API package-- was introduced with J2SE 1.4 in 2002. Java NIO's purp ...
- 利用jpedal进行pdf转换成jpeg,jpg,png,tiff,tif等格式的图片
项目中运用到pdf文件转换成image图片,开始时使用pdfbox开源库进行图片转换,但是转换出来的文件中含有部分乱码的情况.下面是pdfBox 的pdf转换图片的代码示例. try{ String ...
- 关于ajaxfileupload.js一些问题和上传图片就立即显示图片功能
ajaxfileupload.js是上传文件的一个插件,最近碰到的一个问题是在谷歌浏览器上传文件之后,原文本框中的文件名称消失,网上搜了好长时间也没有十分满意的答案.无刷新上传文件我想到的只有ajax ...