UVA-10056 - What is the Probability?
Posted by Yung-Sheng Lu 14 Apr 2018
- UVa Online Judge 解題結果請於 Submit 後,參閱 uHunt。
- 如果你有任何建議與指教,歡迎於下方留言一起討論喔!
- 本題選為「20170523 大學程式能力檢定 CPE」題目。
題意概要
題目給定全部人數、每個人獲勝的機率,並給定所要求第幾個人獲勝的機率。
- 分析:由簡單的機率觀念,假設全部有 人,每個人獲勝的機率都是 ,則輸掉的機率為 。
- 第一回合
- 第一個人獲勝的機率:。
- 第二個人獲勝的機率:。
- 第三個人獲勝的機率:。
- 第個人獲勝的機率:。
- 第二回合:假設第一回合每個人都輸掉。
- 第一個人獲勝的機率:。
- 第二個人獲勝的機率:。
- 第三個人獲勝的機率:。
- 第個人獲勝的機率:。
- 第回合:
- 第個人獲勝的機率:。
- 唯獨要注意的是,本題要做到小於 才行。
- 第一回合
Input
Input will contain an integer () at first, which indicates how many sets of inputs are there. The next lines will contain sets of inputs. Each line contain an integer () which denotes the number players, a floating point number which indicates the probability of the happening of a successful event in a single throw (If success means getting then is the probability of getting in a single throw. For a normal dice the probability of getting is ), and () the serial of the player whose winning probability is to be determined (Serial no varies from to ). You can assume that no invalid probability () value will be given as input.
Output
For each set of input, output in a single line the probability of the -th player to win. The output floating point number will always have four digits after the decimal point as shown in the sample output.
Sample Input
2
2 0.166666 1
2 0.166666 2
Sample Output
0.5455
0.4545