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 ...
随机推荐
- go 学习之路(二)
一.文件名 关键字 标识符 所有go源码都以.go结尾 标识符以字母或下划线开头,大小写敏感 a.boy b.Boy c.a+b d.0boy e._boy f.=_boy g._ 以上变量c.d.f ...
- 一文了解:Redis事务
Redis事务 事务提供了一种"将多个命令打包,一次性提交并按顺序执行"的机制,提交后在事务执行中不会中断.只有在执行完所有命令后才会继续执行来自其他客户的消息. Redis中的使 ...
- 【JDK】JDK源码分析-ReentrantLock
概述 在 JDK 1.5 以前,锁的实现只能用 synchronized 关键字:1.5 开始提供了 ReentrantLock,它是 API 层面的锁.先看下 ReentrantLock 的类签名以 ...
- .NETCoreCSharp 中级篇2-3 Linq简介
.NETCoreCSharp 中级篇2-3 本节内容为Linq及其拓展方法.Linq中表达式树的使用 简介 语言集成查询(LINQ)是一系列直接将查询功能集成到C#语言的技术统称.数据查询历来都表示为 ...
- [转载]MongoDB管理基础
1. 启动和停止MongoDB: 执行mongod命令启动MongoDB服务器.mongod有很多可配置的选项,我们通过mongod --help可以查看所有选项,这里仅介绍一些主要选项: - ...
- Spring1
一.Spring是什么?有什么用? Spring的适用环境是这样的,假设现在有一个类port,它将提供一个返回消息的功能,代码如下: public class port { private weibo ...
- 发布一个自己的jar包给全球人使用
目录 项目准备 sonatype 注册 申请sonatype工单 gpg配置 项目配置 依赖oss-parent 自定义配置 pom配置 全局settings配置 发布 验证 maven 项目对于我们 ...
- Spring参数的自解析--还在自己转换?你out了!
背景前段时间开发一个接口,因为调用我接口的同事脾气特别好,我也就不客气,我就直接把源代码发给他当接口定义了. 没想到同事看到我的代码问:要么 get a,b,c 要么 post [a,b,c]. ...
- MySQL--单表查询、多表查询简单概述
表的前期准备: create table emp( id int not null unique auto_increment, name ) not null, sex enum('male','f ...
- Appium+python自动化(三十五)- 命令启动appium之 appium服务命令行参数(超详解)
简介 前边介绍的都是通过按钮点击启动按钮来启动appium服务,有的小伙伴或者童鞋们乍一听可能不信,或者会问如何通过命令行启动appium服务呢?且听宏哥一一道来. 一睹为快 其实相当的简单,不看不知 ...