Combat Odds
Time limit1sMemory limit256 MB
Given N independent battles with win chance p, compute the chance that a losing run of at least L occurs.
- Level
Medium5 of 10
- Topics
- Probability, Dynamic programming
- Solved
- No attempts yet
Problem
On game forums there is always someone who blames the game for his own losses. A lack of realism or a cheating AI are the usual charges. Most of the time the real problem is skill.
The latest complaint comes from a player who says the computer cheats in the game he just bought. A battle is reported as a 70% chance to win and he loses it anyway. Another player takes his side and adds that he has lost five such battles in a row. The probability of that is , so the game cannot be honest, he says. That number is right only if those five battles are the only ones that ever happen. A single game contains far more battles than five, so the chance that such a streak shows up somewhere is much larger. You decide to compute it yourself.
A battle ends in a win or a loss, and the probability of a win is . Given battles, find the probability that a losing streak of length at least appears at least once. Battle outcomes are independent of each other and the random number generator is fair.
Input
The first line contains the number of test cases . Each of the next lines contains , and for one test case, separated by whitespace.
Output
For each test case, print on its own line the probability that a losing streak of length at least appears. Round the value to exactly nine digits after the decimal point and pad with zeros when digits are missing.