HDU5159 Card
来源:互联网 发布:linux route 修改路由 编辑:程序博客网 时间:2024/06/03 17:45
Card
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 429 Accepted Submission(s): 163
Special Judge
Problem Description
There are x cards on the desk, they are numbered from 1 to x. The score of the card which is numbered i(1<=i<=x) is i. Every round BieBie picks one card out of the x cards,then puts it back. He does the same operation for b rounds. Assume that the score of the j-th card he picks is Sj . You are expected to calculate the expectation of the sum of the different score he picks.
Input
Multi test cases,the first line of the input is a number T which indicates the number of test cases.
In the next T lines, every line contain x,b separated by exactly one space.
[Technique specification]
All numbers are integers.
1<=T<=500000
1<=x<=100000
1<=b<=5
In the next T lines, every line contain x,b separated by exactly one space.
[Technique specification]
All numbers are integers.
1<=T<=500000
1<=x<=100000
1<=b<=5
Output
Each case occupies one line. The output format is Case #id: ans, here id is the data number which starts from 1,ans is the expectation, accurate to 3 decimal places.
See the sample for more details.
See the sample for more details.
Sample Input
22 33 3
Sample Output
Case #1: 2.625Case #2: 4.222HintFor the first case, all possible combinations BieBie can pick are (1, 1, 1),(1,1,2),(1,2,1),(1,2,2),(2,1,1),(2,1,2),(2,2,1),(2,2,2)For (1,1,1),there is only one kind number i.e. 1, so the sum of different score is 1.However, for (1,2,1), there are two kind numbers i.e. 1 and 2, so the sum of different score is 1+2=3.So the sums of different score to corresponding combination are 1,3,3,3,3,3,3,2So the expectation is (1+3+3+3+3+3+3+2)/8=2.6251.在每张牌中1~x中·每张牌出现的概率相同2. 1~x中 ,i在这b次中"有"出现的概率是(1-i从不出现) 即1-pow((x-1)/(1.0*x),b*1.0);#include<cstdio>#include<stack>#include<cstring>#include<algorithm>#include<iostream>#include<math.h>using namespace std;long long sum[100010];int main(){ //freopen("G://test.txt","r",stdin); int m,n,t,x,b,count=0; sum[0]=0; for(int i=1;i<=100000;++i){ sum[i]=sum[i-1]+i; } scanf("%d",&t); while(t--){ count++; scanf("%d%d",&x,&b); double fin; double p=1-pow((x-1)/(1.0*x),b*1.0); fin=sum[x]*p; printf("Case #%d: %.3lf\n",count,fin); } return 0;}
0 0
- HDU5159 Card
- 【HDU5159】【BestCoderRound26.1002】Card
- hdu5159 Card(组合数学)BC26
- HDU5159--BC--Card(概率写法,和组合写法)
- hdu5159 求和题
- card
- Card
- 1012 card card card
- HDU6205 card card card
- HDU6205-card card card
- card card card
- HDU6205 card card card
- HDU6205 card card card【模拟】
- hdu 6205 card card card
- HDU 6205:card card card
- HDU 6205 card card card
- hdu 6205 card card card
- card card card HDU-6205
- C++11 中的线程、锁和条件变量
- 解剖Nginx·模块开发篇(1)跑起你的 Hello World 模块!
- 八、Redis 基础命令---管理--持久化--RDB
- 交换两个变量的值
- C++11 中值得关注的几大变化(详解)
- HDU5159 Card
- 那些年我们一起追过的缓存写法(一)
- 交换两个变量的值
- peakdet: Peak detection using MATLAB 峰识别 峰面积计算 peak area 相关matlab基本详解
- 【Linux】tar命令的使用
- CSS垂直树形下拉菜单的制作方法
- 递归与尾递归(C语言)
- pyinstaller打包
- 锁屏总结