这道题的知识点第一次听说 ,就是应用斯特林数。题目的意思是给你房间数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. myEclipse异常解决:Errors occurred during the build. Errors running builder Mule 3 hot deployment

    选择一个项目—-右键Properties—-Builders—-取消 “JavaScript Validator”  和 Mule 3 hot deployment 的勾就OK了 根据具体异常,勾选. ...

  2. NuGet Package 管理工具

    http://npe.codeplex.com/downloads/get/clickOnce/NuGetPackageExplorer.application

  3. DPDK2.1开发者手册1-2

    Programmer’s Guide Release 2.1.0 翻译的目的是强化自己对dpdk的理解,看看2.1版本和现在使用的版本的差异,其次就是可能要走了,为那些要上手dpdk,但是又不想看英文 ...

  4. JAVA 面试整理,面试汇总

    1.JAVA是通过重写和重载来实现多态性的. 重写:同样的方法签名,不同的方法实现 重载:同样的方法名,不同的参数类型或参数个数 2.JAVA中如果存在不再使用的对象,但是程序又持有该对象的引用,就会 ...

  5. jquery1.7.2的源码分析(六)基本功能

    jQuery.fn.extend({ attr: function( name, value ) { return jQuery.access( this, jQuery.attr, name, va ...

  6. ORACLE_CLASS_ENDING

    [JSU]LJDragon's Oracle course notes In the first semester, junior year Oracle考前复习 试题结构分析: 1.选择题2x10, ...

  7. js高级教程第3版笔记(我的理解)陆续更新中

    js基础语法'use strict'(严格模式)定义变量var object;只声明未赋值,默认值为undefined;var object1=值;声明并赋值;function fun(a){这样也叫 ...

  8. (Relax 数论1.8)POJ 1284 Primitive Roots(欧拉函数的应用: 以n为模的本原根的个数phi(n-1))

    /* * POJ_2407.cpp * * Created on: 2013年11月19日 * Author: Administrator */ #include <iostream> # ...

  9. 五、SolrJ、Request Handler

    什么是SolrJ 既然Solr是以单独的WebApp形式存在的,那么Solr理应提供与Solr通信的Api吧,对的,这就是SolrJ,既然与solr通信是通过url,那么其实我们也可以不用SolrJ, ...

  10. 使用const 提高函数的健壮性

    1.如果输入参数采用“指针传递”,那么加const 修饰可以防止意外地改动该指针指向的内存单元,起到保护的作用. 例如:void StringCopy(char *strDest, const cha ...