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 ...
随机推荐
- 正则表达式【TLCL】
grep[global regular expression print] print lines matching a pattern grep [options] regex [file...] ...
- windchill系统——开发_生命周期状态的增加
步骤如下 ResourceBuild wt.lifecycle.StateRB ant -f codebase/MakeJar.xml 这样就可以了,下面是查看
- Android中获取屏幕高度和宽度
有时我们需要获取当前屏幕的高度和宽度,只需要在一个Activity的onCreate()方法中写上如下代码即可: //定义DisplayMetrics 对象 DisplayMetrics metric ...
- Spring 静态注入讲解(MethodInvokingFactoryBean)
/* * Copyright (c) 2017 4PX Information Technology Co.,Ltd. All rights reserved. */package com.fpx.o ...
- php模拟发送GET和POST请求
php分别模拟发送GET和POST请求,非常实用的额,也可作PHP CURL入门级的理解教材的,示例代码如下: <?php /* ** php分别模拟发送GET与POST请求 ** */ fun ...
- 交换机上的trunk,hybrid,access配置和应用(转)
交换机上的trunk,hybrid,access配置和应用 以太网端口的链路类型: Access类型:端口只能属于一个vlan,一般用于连接计算机. Trunk类型:端口可以属于端个vlan,可以接收 ...
- 关于Action和EventHandler
.net框架自带的两个常用类(Action和EventHandler),当然这两个类型的也可以自定义,但系统已经提供,直接拿来用即可,很方便 1:Action : 引用“void方法”的委托,目前框架 ...
- notepad++去空格空行技巧
选择视图显示所有字符,替换成空的就行
- Elasticsearch 文档专用
ES安装等操作 http://blog.csdn.net/cnweike/article/details/33736429 https://www.elastic.co/guide/cn/elasti ...
- react-redux: async promise
1.the simple sample action: 事实上,只是返回个一个至少包含type的对象{ },用于reducer接收. import {RECEIVE_DATA} from " ...