hdu Examining the Rooms
来源:互联网 发布:log4j输出mybatis sql 编辑:程序博客网 时间:2024/05/18 15:05
这道题的知识点第一次听说 ,就是应用斯特林数。题目的意思是给你房间数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[30],a[30][30];void inti(){ f[1]=1; f[0]=1; for(int i=2; i<=20; i++) { f[i]=f[i-1]*i; } for(int i=1; i<=20; i++) { a[i][0]=0; } for(int i=1; i<=20; i++) { for(int j=1; j<=i; j++) { if(i==j) a[i][j]=1; else a[i][j]=a[i-1][j-1]+(i-1)*a[i-1][j]; } } for(int i=1; i<=20; i++) { for(int j=1; j<=20; 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=0; for(int i=1; i<=k; i++) { sum+=(a[n][i]-a[n-1][i-1]); } printf("%.4lf\n",sum*1.0/f[n]); } return 0;}
0 0
- HDU Examining the Rooms
- hdu Examining the Rooms
- hdu 3625 Examining the rooms
- hdu 3625 Examining the Rooms
- HDU 3625 Examining the Rooms
- HDU 3625 Examining the Rooms
- hdu 3625 Examining the Rooms
- HDU 3625 Examining the Rooms
- HDU-3625-Examining the Rooms
- Examining the Rooms hdu 3625
- HDU 3625 Examining the Rooms
- HDU 3625 Examining the Rooms
- 斯特灵数 hdu 3625 Examining the Rooms
- [Stirling] HDU 3625 Examining the Rooms
- HDU 3625 Examining the Rooms(斯特林数)
- hdu 3625 Examining the Rooms(斯特林数)
- Examining the Rooms
- Examining the Rooms
- Java 学习笔记 开发环境搭建JDK+Tomcat+Eclipse
- (摘抄笔记)人脸识别必读的N篇文章
- UVA 代码说明
- 内存管理内幕 - 动态分配的选择、折衷和实现
- 项目阶段学习总结(设计集合框架、JPA、个人思路)
- hdu Examining the Rooms
- 单向链表插入排序 Java
- dedecms支持weight排序功能修改
- LayoutInflater作用及使用
- IOS声音调用
- Linux根目录下各个目录的作用
- Panel Paint事件
- jquery调用方法
- 微软2014年实习生在线机试第二题及解法