多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國內(nèi)最全I(xiàn)T社區(qū)平臺 聯(lián)系我們 | 收藏本站
阿里云優(yōu)惠2
您當(dāng)前位置:首頁 > web前端 > htmlcss > light oj 1248 - Dice (III)(期望)

light oj 1248 - Dice (III)(期望)

來源:程序員人生   發(fā)布時間:2015-05-20 10:47:56 閱讀次數(shù):3685次

Given a dice with n sides, you have to find the expected number of times you have to throw that dice to see all its faces at least once. Assume that the dice is fair, that means when you throw the dice, the probability of occurring any face is equal.

For example, for a fair two sided coin, the result is 3. Because when you first throw the coin, you will definitely see a new face. If you throw the coin again, the chance of getting the opposite side is 0.5, and the chance of getting the same side is 0.5. So, the result is

1 + (1 + 0.5 * (1 + 0.5 * ...))

= 2 + 0.5 + 0.52 + 0.53 + ...

= 2 + 1 = 3

Input

Input starts with an integer T (≤ 100), denoting the number of test cases.

Each case starts with a line containing an integer n (1 ≤ n ≤ 105).

Output

For each case, print the case number and the expected number of times you have to throw the dice to see all its faces at least once. Errors less than 10 will be ignored.

Sample Input

Output for Sample Input

5

1

2

3

6

100

Case 1: 1

Case 2: 3

Case 3: 5.5

Case 4: 14.7

Case 5: 518.7377517640

 

#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> #include<queue> #include<stack> #include<vector> #include<set> #include<map> #define L(x) (x<<1) #define R(x) (x<<1|1) #define MID(x,y) ((x+y)>>1) #define eps 1e⑻ //typedef __int64 ll; #define fre(i,a,b) for(i = a; i <b; i++) #define free(i,b,a) for(i = b; i >= a;i--) #define mem(t, v) memset ((t) , v, sizeof(t)) #define ssf(n) scanf("%s", n) #define sf(n) scanf("%d", &n) #define sff(a,b) scanf("%d %d", &a, &b) #define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c) #define pf printf #define bug pf("Hi ") using namespace std; #define INF 0x3f3f3f3f #define N 100005 double dp[N]; int n; int main() { int i,j,t,ca=0; sf(t); while(t--) { sf(n); mem(dp,0); for(i=n⑴;i>=0;i--) dp[i]=((n-i)*dp[i+1]+n)*1.0/(n-i); pf("Case %d: %.7lf ",++ca,dp[0]); } return 0; }







生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關(guān)閉
程序員人生
主站蜘蛛池模板: 日韩欧美毛片免费观看视频 | 无毒三级| 亚洲欧美视频一区 | 亚洲成网站www久久九 | 国产一及毛片 | 一区二区三区四区五区 | 图片区小说区号综合区 | 久久精品免费在线观看 | 久久精品免费播放 | 日本美女一级黄色片 | 国内自拍亚洲 | 日本一二三区在线视频 | 亚洲精品午夜久久aaa级久久久 | 性感美女视频免费网站午夜 | 午夜免费福利片观看 | 亚洲综合在线视频 | xh98hx国产在线视频 | 精品久久久久久国产免费了 | 精品在线一区二区三区 | 夜夜精品视频一区二区 | 亚洲视频网站在线观看 | 欧美成人免费全部观看天天性色 | 欧美性videos高清另类hd | 国产成人精品一区二三区 | 国产国产人在线成免费视频69 | xxx日韩| 亚洲精品日本 | 一级做a爰片性色毛片新版的 | 国产午夜精品不卡观看 | 亚洲综合五月 | 久久欧美精品 | 亚洲国产激情在线一区 | 五月天在线观看免费视频播放 | 欧美最猛性xxxxx(亚洲精品) | 一级毛片在线免费看 | 波多野结衣亚洲一区二区三区 | 手机福利片 | 欧美亚洲国产激情一区二区 | 一区二区三区鲁丝不卡麻豆 | 国产香蕉一区二区在线观看 | 欧美日一区二区三区 |