日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國內(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ù):3691次

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ìn)行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關(guān)閉
程序員人生
主站蜘蛛池模板: 欧美在线网站 | 中文在线√天堂 | 国产精品久久久久久一区二区 | 亚洲综合a| 国产精品视频久久 | 懂色av蜜臀av粉嫩av分享 | 亚洲第一视频 | 91亚洲精品在线 | 久久综合久久综合久久 | 热久久久久久 | 亚洲欧美日韩成人 | 国产精品久久久久久久三级 | 91大片淫黄大片在线天堂 | 波多野结衣中文字幕久久 | 91国内| 日本aa大片在线播放免费看 | 亚洲精品尤物福利在线一区 | 国产精品国产三级国产aⅴ9色 | 男人电影天堂 | 成人免费网址 | 亚洲综合在线视频 | 精品国产乱码一区二区三区 | 99精品网| 97国产一区二区精品久久呦 | 成人免费专区 | 久久久精 | 中文字幕在线播放第一页 | 免费的三级毛片 | 久久成人综合网 | av亚洲在线| 久久大陆| 久久精品国产一区二区三区 | 黄色片看| 黄色av国产 | 久久福利精品 | 黄色大片网站 | 嫩草免费视频 | 久久久久久国产免费 | 国产精品区一区二区三 | 国产精品s | 久久日本片精品aaaaa国产 |