410321: GYM104009 E Coins

Memory Limit:1024 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

E. Coinstime limit per test1 secondmemory limit per test1024 megabytesinputstandard inputoutputstandard output

It is time for yet another coins problem. Ionel found a 50 $$$bani$$$ coin on the street. If this happened 10 years ago, he would have been able to just consider himself lucky and buy some bread or some candy.

Unfortunately, this mysterious phenomenon called inflation has been happening, so he cannot really buy much with that coin these days. Therefore, he decided to at least play with it. Namely, if he flips the coin, Ionel will either get head or tails. He's so fascinated by this that he is thinking of flipping the coin $$$N$$$ ($$$1 \leq N \leq 10^6$$$) times. By doing so, he realizes that the expected number of distinct substrings of $$$K$$$($$$1 \leq K \leq N$$$) tails is $$$X$$$.

Now you might be confused: Ionel is giving all of this talk about an expected value, but there is no probability in sight. That is indeed the case - Ionel knows that there is a chance of $$$p$$$ of rolling tail and a chance of $$$1-p$$$ of rolling head. Weirdly enough, he does not actually know the value of this $$$p$$$. However, with the information that you're given, you might be able to find out and get one more accepted submission for the contest.

Formally, you are given a coin which can be flipped to head or to tail. This coin will be flipped $$$N$$$ times. Moreover, you also know $$$X(0 \leq X \leq N-K+1)$$$, which is the expected value for the number of times you can get a substring of length $$$K$$$ which is made only of tails.

What is the probability $$$p$$$ of rolling tail, given this information? We guarantee that $$$p$$$ will have a precision of $$$10^{-7}$$$.

Input

On the first line, you are given an integer $$$T$$$ denoting $$$T$$$ different test cases, where $$$1 \leq T \leq 10^3$$$. The next $$$T$$$ lines will contain three values: an integer $$$N (1 \leq N \leq 10^6)$$$, referring to how many times a coin will be flipped, an integer $$$K (1 \leq K \leq N)$$$, referring to the length $$$K$$$ of each individual streak of tails, and a decimal positive value $$$X(0 \leq X \leq N-K+1)$$$, referring to the expected number of tail streaks of length $$$K$$$.

Output

On $$$T$$$ lines, print $$$p_u$$$, the probability of rolling tail for the given coin.

ExampleInput
3
10 3 3.432
10 3 0
10 3 8
Output
0.754198673
0.000000000
1.000000000

加入题单

算法标签: