| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 4 초 | 2048 MB | 5 | 5 | 5 | 100.000% |
Lucy is a frequent arcade visitor. All machines at the arcade give out tickets to exchange for prizes! Lucy's favorite machine works as follows.
The machine only has two buttons: "Roll" and "Withdraw". Whenever Lucy presses "Roll", the machine increases the counter on the screen by a randomly generated real number between 0ドル$ and $d$. At any moment, she can press "Withdraw" to get the number of tickets equal to the counter, which gets reset. In case it's not an integer, the machine generously rounds the counter up before handing out the tickets.
More formally, the machine stores a real number $S,ドル initially equal to 0. On each "Roll" press, the machine generates $\Delta$ --- a random real number picked uniformly from the interval $(0, d)$. Then, $S$ increases by the value of $\Delta$. When the "Withdraw" button is pressed, the machine rounds $S$ up, giving the player $\lceil S \rceil$ tickets, and then resets $S$ back to zero. Lucy can see the value of $S$ on the screen at any moment with as much precision as she wants, and she can use it to decide whether to roll or withdraw.
Lucy has enough arcade tokens to press "Roll" $n$ times, and "Withdraw" $k$ times. Find a strategy that maximizes the expected number of tickets Lucy can get, and print this maximum expected number.
Each test contains multiple test cases. The first line contains the number of test cases $t$ (1ドル \le t \le 2000$). The description of the test cases follows.
The only line of each test case contains three integers $n,ドル $k,ドル and $d,ドル denoting the number of rolls, the number of withdrawals, and the upper bound on roll values (1ドル \le k \le n \le 2000$; 1ドル \le d \le 2000$).
For each test case, print the maximum expected number of tickets Lucy can get, as a floating point number. Your answer will be considered correct if its absolute or relative error doesn't exceed 10ドル^{-6}$.
3 3 2 1 5 5 3 7 1 10
2.6250000000 10.0000000000 35.5000000000
In the first test case, with $n = 3$ rolls, $k = 2$ withdrawals, and $d = 1,ドル the optimal strategy is as follows:
Lucy starts with a roll. Depending on the number $S,ドル there are two possibilities:
Each case happens with probability $\frac 12,ドル so the total expected value for this strategy is $\frac 12 (2.5 + 2.75) = 2.625$.
In the second test case, Lucy can withdraw after every roll, each time getting 2ドル$ tickets on average.
In the third test case, Lucy can only withdraw once, and she should do it after all 7ドル$ rolls.