P28264 [洛谷] [LnOI2019] Gatling Roulette
提高
题目描述

Background

Gatling Roulette is a health-oriented game.

Problem Description

Unlike the Russian Roulette which uses a pistol, Gatling Roulette employs a Gatling gun as the gambling tool.

The rules of Gatling Roulette are straightforward: bullets are loaded into some chambers of the Gatling gun. Participants sit around a circular table and take turns aiming the Gatling gun at their own heads and pulling the trigger for one second. Those who get shot are automatically out, and the last one standing is the winner.

We use the latest 2019 technology Gatling gun, which features no need for preheating and unlimited bullets. Each participant has an identical probability $P_0$ of getting shot in every round.

Each game involves $n$ long-necked deer, starting from the first one and proceeding in ascending order of their numbers, continuously cycling around the table.

The game may loop through multiple rounds until only one long-necked deer remains, at which point the game ends.

Given $P_0$ and $n$, query the probability $P_k$ that the $k$-th long-necked deer becomes the sole survivor.

If $P_0 = 0$, we consider the winner to be the 1st long-necked deer.

Input Format

A single line containing three numbers: $P_0, n, k$.

Output Format

A floating-point number $P_k$, with an error less than $10^{-8}$. (Please retain more decimal places)

Sample Input and Output

Sample Input #1

0.5 2 1

Sample Output #1

0.33333333

Sample Input #2

0.5 2 2

Sample Output #2

0.66666667

Sample Input #3

0.5 3 1

Sample Output #3

0.23809524

Sample Input #4

0.5 3 2

Sample Output #4

0.28571429

Notes

  • For $10\%$ of the data, $n \le 100$.
  • For $30\%$ of the data, $n \le 500$.
  • For another $20\%$ of the data, $k = n$.
  • For $100\%$ of the data, $1 \le k \le n \le 10^{4}, 0 \le P_0 \le 1$.

All data have a time limit of 1000ms and a space limit of 256MB, with O2 optimization enabled.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
0.5 2 1
样例输出
0.33333333