hdu1521 排列组合 指数型母函数模板题
排列组合
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4891 Accepted Submission(s): 2122
1 1
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <string>
#include <cstring>
#include <iterator>
#include <iostream>
#include <algorithm>
#define debug(a) cout << #a << " " << a << endl
using namespace std;
const int maxn = 2*1e2 + 10;
const int mod = 10000;
typedef long long ll;
ll f( ll x ) {
ll sum = 1;
for( ll i = 1; i <= x; i ++ ) {
sum *= i;
}
return sum;
}
int main() {
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
ll n, m, num[maxn];
double a[maxn], b[maxn];
while( cin >> n >> m ) {
memset( a, 0, sizeof(a) );
memset( b, 0, sizeof(b) );
for( ll i = 0; i < n; i ++ ) {
cin >> num[i];
}
for( ll i = 0; i <= num[0]; i ++ ) {
a[i] = 1.0/f(i);
}
for( ll i = 1; i < n; i ++ ) {
for( ll j = 0; j <= n; j ++ ) {
for( ll k = 0; k <= num[i] && k+j <= n; k ++ ) {
b[k+j] += a[j]/f(k);
}
}
for( ll j = 0; j <= n; j ++ ) {
a[j] = b[j], b[j] = 0;
}
}
printf("%.lf\n",a[m]*f(m) );
}
return 0;
}
hdu1521 排列组合 指数型母函数模板题的更多相关文章
- hdu1521 排列组合(指数型母函数)
题意: 有n种物品,并且知道每种物品的数量ki.要求从中选出m件物品的排数. (全题文末) 知识点: 普通母函数 指数型母函数:(用来求解多重集的排列问题) n个元素,其中a1,a2, ...
- hdu1521:排列组合---指数型母函数
题意: n种元素,每种有 ni个,选出 m 个的排列有多少种 题解: 指数型母函数的裸题 x^n 项的系数为 an/n!.... 代码如下: #include <iostream> #i ...
- HDU 1521 排列组合 指数型母函数
排列组合 Time Limit: 1000MS Memory Limit: 32768KB 64bit IO Format: %I64d & %I64u Submit Status D ...
- HDU 2079 选课时间(母函数模板题)
链接:传送门 思路:母函数模板题 /************************************************************************* > Fil ...
- 【指数型母函数】hdu1521 排列组合
#include<cstdio> #include<cstring> using namespace std; int n,m,jiecheng[11]; double a[1 ...
- HDU2082母函数模板题
找单词 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submis ...
- HDU 1521 排列组合 (母函数)
题目链接 Problem Description 有n种物品,并且知道每种物品的数量.要求从中选出m件物品的排列数.例如有两种物品A,B,并且数量都是1,从中选2件物品,则排列有"AB&qu ...
- HDU 2082 母函数模板题
找单词 Time Limit: 1000MS Memory Limit: 32768KB 64bit IO Format: %I64d & %I64u Submit Status De ...
- HDU1028 Ignatius and the Princess III 【母函数模板题】
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
随机推荐
- java的jar打包工具的使用
java的jar打包工具的使用 java的jar是一个打包工具,用于将我们编译后的class文件打包起来,这里面主要是举一个例子用来说明这个工具的使用. 在C盘下的temp文件夹下面: ...
- win10教育版激活错误:在运行 Microsoft Windows 非核心版本的计算机上,运行"slui.exe ...”
折腾了一天,最终轻松解决,先启用Software Protection服务,在激活(密钥或者工具都行). PS:但是这样还是无法解决Software Protection自动停止的问题,这个可以参考网 ...
- 两份简单的logstash配置
input{http{port=>7474}} filter{ grok{ match =>{ #"message" => "%{COMBINEDAPA ...
- AUTOSAR学习之RTE - 可运行实体
本文介绍RTE的运行体(runnable). An AUTOSAR component defines one or more "runnable entities". A run ...
- Redis总结(八)如何搭建高可用的Redis集群
以前总结Redis 的一些基本的安装和使用,大家可以这这里查看Redis 系列文章:https://www.cnblogs.com/zhangweizhong/category/771056.html ...
- 使用nginx代理centos yum 源
我们在安装centos 服务器时,可能会有以下情况: 局域网内有若干台服务器,但是只有一台服务器可以连接外网,其余服务器都不可以连接外网,但通过局域网与外网机器联通. 那么我们再使用 yum 安装软件 ...
- 【Java例题】2.7找零钱
7.为顾客找零钱时,希望选用的纸币张数最少. 例如73元,希望零钱的面值为五十元1张,二十元1张,一元3张. 设零钱面值有五十元.二十元.十元.五元和一元, 请编写程序,用户输入100以下的数, 计算 ...
- 基于RobotFramework实现自动化测试
Java + robotframework + seleniumlibrary 使用Robot Framework Maven Plugin(http://robotframework.org/Mav ...
- python编写环境(种类)
python编写环境(种类) 官方推荐 cpython 转成C的字节码 jython转成Java的字节码 ironpython转成C#字节码 pypy转换成动态编译 开发快,运行快
- Java——数据结构(顺序表)
这是一个顺序表的类,初始化的时候就已经确定了表的长度,之后不能添加数据,因为使用的是数组存储的数据,不过这个表的类型是泛型的. public class List { private Object[] ...