hdu 3625 Examining the Rooms——第一类斯特林数
题目:http://acm.hdu.edu.cn/showproblem.php?pid=3625
n^2 求斯特林数就行。要减去的就是1号钥匙在1号房间的方案,即 s[ n-1 ][ m-1] 。
注意是 <=m 。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=;
int T,n,m;ll jc[N],s[N][N];
void init()
{
jc[]=;for(int i=;i<=;i++)jc[i]=jc[i-]*i;
s[][]=;
for(int i=;i<=;i++)
for(int j=;j<=i;j++)
s[i][j]=s[i-][j]*(i-)+s[i-][j-];
}
int main()
{
init();
scanf("%d",&T);
while(T--)
{
scanf("%d%d",&n,&m);
ll ans=;
for(int i=;i<=m;i++)ans+=s[n][i]-s[n-][i-];
printf("%.4f\n",(double)ans/jc[n]);
}
return ;
}
hdu 3625 Examining the Rooms——第一类斯特林数的更多相关文章
- [HDU 3625]Examining the Rooms (第一类斯特林数)
[HDU 3625]Examining the Rooms (第一类斯特林数) 题面 有n个房间,每个房间有一个钥匙,钥匙等概率的出现在n个房间内,每个房间中只会出现且仅出现一个钥匙.你能炸开门k次, ...
- hdu 3625 Examining the Rooms —— 第一类斯特林数
题目:http://acm.hdu.edu.cn/showproblem.php?pid=3625 学习斯特林数:https://blog.csdn.net/qq_33229466/article/d ...
- hdu 3625 Examining the Rooms 轮换斯特林数
题目大意 n个房间对应n把钥匙 每个房间的钥匙随机放在某个房间内,概率相同. 有K次炸门的机会,求能进入所有房间的概率 一号门不给你炸 分析 我们设\(key_i\)为第i间房里的钥匙是哪把 视作房间 ...
- HDU 3625 Examining the Rooms【第一类斯特灵数】
<题目链接> <转载于 >>> > 题目大意:有n个锁着的房间和对应n扇门的n把钥匙,每个房间内有一把钥匙.你可以破坏一扇门,取出其中的钥匙,然后用取出钥匙打 ...
- HDU 4372 Count the Buildings——第一类斯特林数
题目大意:n幢楼,从左边能看见f幢楼,右边能看见b幢楼 楼高是1~n的排列. 问楼的可能情况 把握看到楼的本质! 最高的一定能看见! 计数问题要向组合数学或者dp靠拢.但是这个题询问又很多,难以dp ...
- HDU 3625 Examining the Rooms:第一类stirling数
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3625 题意: 有n个房间,每个房间里放着一把钥匙,对应能开1到n号房间的门. 除了1号门,你可以踹开任 ...
- HDU 4372 Count the Buildings [第一类斯特林数]
有n(<=2000)栋楼排成一排,高度恰好是1至n且两两不同.现在从左侧看能看到f栋,从右边看能看到b栋,问有多少种可能方案. T组数据, (T<=100000) 自己只想出了用DP搞 发 ...
- HDU 3625 Examining the Rooms
题目大意:有n个房间,n!个钥匙,在房间中,最多可以破k扇门,然后得到其中的钥匙,去开其它的门,但是第一扇门不可以破开,求可以打开所有门的概率. 题解:首先,建立这样的一个模型,题目相当于给出一个图, ...
- 【组合数学:第一类斯特林数】【HDU3625】Examining the Rooms
Examining the Rooms Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
随机推荐
- 关于 Content-Type:application/x-www-form-urlencoded 和 Content-Type:multipart/related(转)
最近项目中用到的一个是用一个页面接收c程序post过来的一断字符串..总接收不到值... 我用C#写一个测试可以正常接收到值. 最后抓包比较 区别只是 Content-Type:application ...
- Aware接口
Aware接口: 例如: BeanNameAware接口是为了让自身Bean能够感知到,获取到自身在Spring容器中的id属性. 同理,其他的Aware接口也是为了能够感知到自身的一些属性. 比如实 ...
- PasswordHasher 算法
public override PasswordVerificationResult VerifyHashedPassword(string hashedPassword, string provid ...
- springBean集合注入的方法
applicationContext.xml <?xml version="1.0" encoding="UTF-8"?> <beans xm ...
- 使用VirtualBox安装Android 4.2.2 x86 .
http://blog.csdn.net/kunoy/article/details/8768205 virtual box 安装 android x86 不显示鼠标, --> 控制 --> ...
- Spring -- spring结合aop 进行 tx&aspectj事务管理配置方法
1. tx 配置方法, 代码示例 javabean及其映射文件省略,和上篇的一样 CustomerDao.java, dao层接口 public interface CustomerDao { pub ...
- TCP_AIO_Server_ZC_01
ZC: 这个例子是,1个skt 投递 1个未决的接收操作 1.package aio.Client; 1.1.这是一个 测试的客户端的代码: package aio.Client; import ja ...
- virtio guest side implementation: PCI, virtio device, virtio net and virtqueue
With the publishing of OASIS virtio specification version 1.0, virtio made another big step in becom ...
- Red Hat OpenStack 10的新特性
这是Red Hat有史以来最好的版本,同时也是第一个长生命周期版本(最长五年支持),这篇文章会介绍为什么这是你私有云最好的礼物. 由于要使用命令行,以前安装OpenStack是很繁重的工作.这个版本提 ...
- Spark- 使用第三方依赖解析IP地址
使用 github上已有的开源项目1)git clone https://github.com/wzhe06/ipdatabase.git 2)编译下载的项目: mvn clean package- ...