luogu#P5249. [LnOI2019] 加特林轮盘赌
[LnOI2019] 加特林轮盘赌
Background
Gatling roulette is a wellness game.
Problem Description
Unlike gambling games with pistols such as Russian roulette, the game tool in Gatling roulette is a Gatling gun.
The rules of Gatling roulette are simple: bullets are loaded into some parts of the Gatling’s magazine. The players sit at a round table, and take turns aiming the Gatling at their own head and pulling the trigger for one second. Anyone who gets shot is eliminated immediately. The one who lasts to the end is the winner.
We use a Gatling gun with the latest 2019 technology. Its features are no warm-up needed and unlimited bullets. For each person, in each round, the probability of getting shot is exactly the same, .
There are long-necked deer in each game. Starting from long-necked deer , they play in increasing order by number, going around the round table in a loop.
The game may go through multiple cycles, and ends when only the last long-necked deer remains.
Given and , find the probability that long-necked deer will eventually become the only survivor.
If , we consider deer to be the winner.
Input Format
Only one line with three numbers, .
Output Format
Output a floating-point number . The error should be less than . (Please keep more digits after the decimal point.)
0.5 2 1
0.33333333
0.5 2 2
0.66666667
0.5 3 1
0.23809524
0.5 3 2
0.28571429
Hint
- For of the testdata, .
- For of the testdata, .
- For another of the testdata, .
- For of the testdata, .
For all testdata, the time limit is 1000 ms and the memory limit is 256 MB. optimization is allowed.
Translated by ChatGPT 5