|
<p> |
|
In the game <em>Theatrhythm Final Fantasy</em>, you poke a screen with a stick |
|
to the beat of various songs. The goal is to poke the screen as accurately as |
|
possible. If you hit a note at just the right time, you're awarded a |
|
<strong>critical</strong>. Every song is broken into 20 sections, and if you get a |
|
<strong>critical</strong> on every note in a section, then you get that section's |
|
golden <strong>critical bar</strong>. |
|
</p> |
|
|
|
|
|
<p> |
|
You would like to collect all 20 <strong>critical bars</strong> for every song. |
|
Songs vary in difficulty, but each song has a fixed probability <strong>p</strong>, which |
|
is the chance that you manage to secure any one <strong>critical bar</strong> |
|
on a single playthrough. |
|
The chances are independent, so for any given pair of sections, the probability of |
|
getting both <strong>critical bars</strong> in a single playthrough is <strong>p</strong><sup>2</sup>, and so on. |
|
<strong>Critical bars</strong> are saved between playthroughs, so you don't have to win |
|
all of the <strong>critical bars</strong> in a single play of the song. You might win |
|
the first 10 on one play, and then the last 10 on another. |
|
</p> |
|
|
|
<p> |
|
On average, how many times will you have to play a song to win all 20 |
|
<strong>critical bars</strong>? |
|
</p> |
|
|
|
|
|
|
|
<h3>Input</h3> |
|
|
|
<p> |
|
Input begins with an integer <strong>T</strong>, the number of songs |
|
you'll play. For each song, there is a line containing a floating point number, |
|
<strong>p</strong>, the probability of winning any particular |
|
<strong>critical bar</strong> on a single play of the song. |
|
</p> |
|
|
|
<h3>Output</h3> |
|
|
|
<p> |
|
For each song, output the expected number of times you need to play the song |
|
before acquiring all 20 <strong>critical bars</strong>, rounded to five decimal points. |
|
</p> |
|
|
|
<p> |
|
Absolute errors of up to 10<sup>-5</sup> will be ignored. |
|
</p> |
|
|
|
<h3>Constraints</h3> |
|
<p> |
|
1 ≤ <strong>T</strong> ≤ 20 <br /> |
|
0.01 ≤ <strong>p</strong> ≤ 1.0 <br /> |
|
</p> |
|
|
|
|
|
|
|
|