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 ...
随机推荐
- 02、Java的lambda表达式和JavaScript的箭头函数
前言 在JDK8和ES6的语言发展中,在Java的lambda表达式和JavaScript的箭头函数这两者有着千丝万缕的联系:本次试图通过这篇文章弄懂上面的两个"语法糖". 简介 ...
- oracle 删除用户,提示“无法删除当前已连接的用户”
1. 首先查询出该用户的登录情况,注意用户名必须是大写 SQL> select username,sid,serial# from v$session where username = 'XST ...
- Two types of people with high scores of English exams
I believe that there are two types of people who get high scores in English exams: 1) have high inte ...
- 10.Go-goroutine,waitgroup,互斥锁和channel
10.1.goroutine goroutine的使用 //Learn_Go/main.go package main import ( "fmt" "time" ...
- 原 CNN--卷积神经网络从R-CNN到Faster R-CNN的理解(CIFAR10分类代码)
1. 什么是CNN 卷积神经网络(Convolutional Neural Networks, CNN)是一类包含卷积计算且具有深度结构的前馈神经网络(Feedforward Neural Netwo ...
- golang timeoutHandler解析及kubernetes中的变种
Golang里的http request timeout比较简单,但是稍不留心就容易出现错误,最近在kubernetes生产环境中出现了的一个问题让我有机会好好捋一捋golang中关于timeout中 ...
- spring架构解析--入门一
Spring 框架中的核心组件只有三个:Core.Context 和 Beans.它们构建起了整个 Spring 的骨骼架构.简单理解: spring core是工具,context是环境,而bean ...
- hadoop2.7作业提交详解之文件分片
在前面一篇文章中(hadoop2.7之作业提交详解(上))中涉及到文件的分片. JobSubmitter.submitJobInternal方法中调用了int maps = writeSplits(j ...
- MongoDB Day 1
创建数据库 db.createCollection("user"); 插入字段 //----insert------- db.user.insert({uid:1, user_co ...
- 《Java 8 in Action》Chapter 1:为什么要关心Java 8
自1998年 JDK 1.0(Java 1.0) 发布以来,Java 已经受到了学生.项目经理和程序员等一大批活跃用户的欢迎.这一语言极富活力,不断被用在大大小小的项目里.从 Java 1.1(199 ...