hdu5978 規律 求概率 To begin or not to begin
給k個黑球 1個紅球
先手那個人有優勢 輸 1
先手沒優勢 輸2
先手後手都一樣 輸0
其實如果放回 概率是一樣的
設p為先手贏的概率
1黑1紅 p=1/2 先手抽紅
2黑1紅 p=1/3 + 2/3 * 1/2 = 2/3 第一次抽紅 + 第二到的時候抽紅
3黑1紅 p= 1/4 + 3/4 * 2/3 * 1/2 = 1/2 第一次抽紅 + 第二到的時候抽紅
4黑1紅 p=1/5 + 4/5 * 3/4 * 1/3 + 4/5 * 3/4 * 2/3 * 1/2 = 3/5 。。。。。
p(k黑+1紅) = 1/k+1 + k/k+1 * k-1/k * k-2/k-1 +。。。。+ k/k+1 * k-1/k。。1/2 = (k+2/2)向下取整再 除k+1
(k+2/2)向下取整
若k為奇數 k+2奇 分子是分母一半 輸出0
偶數 分子是分母一半 加1 輸出1
相關推薦
hdu5978 規律 求概率 To begin or not to begin
給k個黑球 1個紅球 先手那個人有優勢 輸 1 先手沒優勢 輸2 先手後手都一樣 輸0 其實如果放回 概率是一樣的 設p為先手贏的概率 1黑1紅 p=1/2 先手抽紅 2黑1紅 p=1/3 + 2/3 *
2016 ICPC大連賽區 hdu5978 To begin or not to begin
To begin or not to begin Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 2
HDU-5978 To begin or not to begin
找規律,k為奇數輸出0,k為偶數輸出1 #include <iostream> using namespace std; int main () { int k; while (cin >> k) { if (k&1) cout &
2016 ICPC大連賽區 [Cloned] H - To begin or not to begin
A box contains black balls and a single red ball. Alice and Bob draw balls from this box without replacement, alternating after each draws until t
PAT 1004 To Fill or Not to Fill (25)
space reac while osi diff font ava possible sso 題目描寫敘述 With highways available, driving a car from Hangzhou to any other city is easy
PAT1092:To Buy or Not to Buy
who ans namespace small 存在 計數 缺失 xtra 長度限制 1092. To Buy or Not to Buy (20) 時間限制 100 ms 內存限制 65536 kB 代碼長度限制 16000 B 判題程序 Standard
1033 To Fill or Not to Fill
erl rom strong put diff 針對 下一個 ont \n PAT A 1033 To Fill or Not to Fill With highways available, driving a car from Hangzhou to any other
PAT (Advanced Level) Practice 1092 To Buy or Not to Buy (20 分)
Eva would like to make a string of beads with her favorite colors so she went to a small shop to buy some beads. There were many colorful strings of b
To be or Not to be that is the question
起因:作為一名程式設計師,我很固執想往需求分析、軟體設計方向發展;一直以來想要參加一個完整的專案,感受專案的每個階段的考慮 事件:自己工作的專案雖然蠻大的,但是一直沒法做自己想做的事情。最近發現開源專案是一個不錯的選擇,於是我參加了一個叫“XX“(不方便)的開源專案,我向專案主管(以下簡稱”
1033 To Fill or Not to Fill (25 分) 貪心演算法
題目 With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to
PAT1092 To Buy or Not to Buy (20 分)
1092 To Buy or Not to Buy (20 分) Eva would like to make a string of beads with her favorite colors so she went to a small shop to buy some beads
PAT1033 To Fill or Not to Fill
With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, w
【PAT甲級】1092 To Buy or Not to Buy
Eva would like to make a string of beads with her favorite colors so she went to a small shop to buy some beads. There were many colorful
PAT-ADVANCED1033——To Fill or Not to Fill
題目描述: 題目翻譯: 1033 加油或不加油 有了高速公路,從杭州開車到任何其他城市都很方便。 但由於汽車的油箱容量有限,我們不得不在途中找到加油站。 不同的加油站可能會給不同的價格。 你需要設計最便宜的路線。 輸入格式: 每個輸入檔案包含一個測試用例
To be or not to be ...
/* 需求:為檔案建立倒排索引 step1: |--為所有的檔案建立索引號 FileID_Number |--首先查詢到所有的檔案目錄 file.list[] |--將所有的檔案寫到一個檔案索引檔案中 fileIndex.txt
PAT (Top Level) Practice1004 To Buy or Not to Buy - Hard Version (35 分)
題目連結:https://pintia.cn/problem-sets/994805148990160896/problems/994805155206119424 暴力,基本上不會超時,dfs加上一些剪枝 演算法:dfs #include<iostream> #includ
PAT (Advanced Level) Practice 1092 To Buy or Not to Buy (20 分)
Eva would like to make a string of beads with her favorite colors so she went to a small shop to buy some beads. There were many colorful
To BQ or not to BQ
Qualifying for the Boston Marathon is a long-standing goal for many marathoners. To qualify runners must achieve a gender and age related cut-off time in a
To BEM or not to BEM?
To BEM or not to BEM?Please note: while I’ve worked as a front-end developer, my primary role has been design or design-related roles (researcher, product
To Censor or not to Censor
To Censor or not to Censor?Recently, a piece of NSFW (or semi-safe-for-work) content was added to my site, and it got me thinking.The content itself is qui