这道题的知识点第一次听说 ,就是应用斯特林数。题目的意思是给你房间数N,和最多能破门的个数,让你求能全部把房间打开的概率!

a[i][j]=a[i-1][j-1]+(i-1)*a[i-1][j];

 #include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std; long long f[],a[][]; void inti()
{
f[]=;
f[]=;
for(int i=; i<=; i++)
{
f[i]=f[i-]*i;
}
for(int i=; i<=; i++)
{
a[i][]=;
}
for(int i=; i<=; i++)
{
for(int j=; j<=i; j++)
{
if(i==j) a[i][j]=;
else
a[i][j]=a[i-][j-]+(i-)*a[i-][j];
}
}
for(int i=; i<=; i++)
{
for(int j=; j<=; j++)
{
a[i][j]=abs(a[i][j]);
}
}
} int main()
{
int t,n,k;
scanf("%d",&t);
inti();
while(t--)
{
scanf("%d%d",&n,&k);
long long sum=;
for(int i=; i<=k; i++)
{
sum+=(a[n][i]-a[n-][i-]);
}
printf("%.4lf\n",sum*1.0/f[n]);
}
return ;
}

hdu Examining the Rooms的更多相关文章

  1. [HDU 3625]Examining the Rooms (第一类斯特林数)

    [HDU 3625]Examining the Rooms (第一类斯特林数) 题面 有n个房间,每个房间有一个钥匙,钥匙等概率的出现在n个房间内,每个房间中只会出现且仅出现一个钥匙.你能炸开门k次, ...

  2. 【组合数学:第一类斯特林数】【HDU3625】Examining the Rooms

    Examining the Rooms Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

  3. Examining the Rooms(dp,斯特灵数)

    Examining the Rooms Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

  4. HDU 3625 Examining the Rooms:第一类stirling数

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3625 题意: 有n个房间,每个房间里放着一把钥匙,对应能开1到n号房间的门. 除了1号门,你可以踹开任 ...

  5. hdu 3625 Examining the Rooms——第一类斯特林数

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=3625 n^2 求斯特林数就行.要减去的就是1号钥匙在1号房间的方案,即 s[ n-1 ][ m-1] . ...

  6. hdu 3625 Examining the Rooms —— 第一类斯特林数

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=3625 学习斯特林数:https://blog.csdn.net/qq_33229466/article/d ...

  7. HDU 3625 Examining the Rooms

    题目大意:有n个房间,n!个钥匙,在房间中,最多可以破k扇门,然后得到其中的钥匙,去开其它的门,但是第一扇门不可以破开,求可以打开所有门的概率. 题解:首先,建立这样的一个模型,题目相当于给出一个图, ...

  8. HDU 3625 Examining the Rooms【第一类斯特灵数】

    <题目链接> <转载于 >>> > 题目大意:有n个锁着的房间和对应n扇门的n把钥匙,每个房间内有一把钥匙.你可以破坏一扇门,取出其中的钥匙,然后用取出钥匙打 ...

  9. hdu 3625 Examining the Rooms 轮换斯特林数

    题目大意 n个房间对应n把钥匙 每个房间的钥匙随机放在某个房间内,概率相同. 有K次炸门的机会,求能进入所有房间的概率 一号门不给你炸 分析 我们设\(key_i\)为第i间房里的钥匙是哪把 视作房间 ...

随机推荐

  1. ortp使用详解1

    一: 关于 oRTP oRTP 是一款开源软件,实现了 RTP 与 RTCP 协议.目前使用 oRTP 库的软件主要是linphone(一款基于IP 进行视频和语音通话的软件). oRTP作为 lin ...

  2. You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.", PowmInsecureWarning

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAApcAAAB3CAIAAADZ1fxtAAAbFElEQVR4nO2dzbHDOo6FHY9S0WqqZt

  3. OpenRisc-44-or1200的pipeline整体分析

    引言 我们在前面分析了ORPSoC,or1200_top,和or1200_cpu的整体架构,在最近,我们也分析了or1200的pipeline(流水线)中的两级,EX级和IF级. 但是,我们还没有从宏 ...

  4. 修改http中的refer(转)

    Referrer的重要性 HTTP请求中有一个referer的报文头,用来指明当前流量的来源参考页.例如在www.sina.com.cn/sports/上点击一个链接到达cctv.com首页,那么就r ...

  5. cdh4.1.2 hadoop和oozie集成问题

    1.异常信息例如以下: Caused by: com.google.protobuf.ServiceException: java.net.ConnectException: Call From sl ...

  6. Java 多字段排序Comparator(兼容Date,Integer,Doubel,Long)

    Java 反射类:ReflexUtil public class ReflexUtil { static Logger logger = LoggerFactory.getLogger(ReflexU ...

  7. oracle tkprof 工具详解

    oracle  tkprof 工具详解 今天是2013-09-26,进行tkprof工具使用学习,在此记录一下笔记: 一)查看需要跟踪会话信息: select s.sid,s.serial#,s.us ...

  8. C++中数组初始化

    #include<iostream>using std::cout;using std::endl;int arr1[5];int arr2[5] = {1,3,5};int main() ...

  9. uva 10560 - Minimum Weight(数论)

    题目连接:uva 10560 - Minimum Weight 题目大意:给出n,问说至少须要多少个不同重量的砝码才干称量1~n德重量,给出所选的砝码重量,而且给出k,表示有k个重量须要用上述所选的砝 ...

  10. Oracle11g新特性之动态变量窥视

    1. 11g之前的绑定变量窥视     我们都知道,为了可以让SQL语句共享运行计划,oracle始终都是强调在进行应用系统的设计时,必须使用绑定变量,也就是用一个变量来取代原来出如今SQL语句里的字 ...