Winning the Match
Time limit1sMemory limit128 MB
Compute the probability that team A wins a best-of-K volleyball match given per-serve win probabilities and a serve-switching rule between rounds and games.
- Level
Medium6 of 10
- Topics
- Dynamic programming, Probability, Math
- Solved
- No attempts yet
Problem
Consider a volleyball match between two teams, and . Under the rules below, compute the probability that team wins the match.
- The match is played by two teams, and .
- The first team to win games wins the match.
- Each game consists of rounds; every round is won by exactly one team, which then scores one point in the current game.
- The first team to reach points wins the game.
- When team serves in a round, it wins that round with probability (and loses it with probability ).
- When team serves in a round, it wins that round with probability (and loses it with probability ).
- Except for the first round of a game, a round is served by the team that won the previous round.
- Except for the first game of the match, the first round of a game is served by the team that did not serve the first round of the previous game.
- In the very first round of the very first game of the match, each team is equally likely to serve.
Given , , , and , compute the probability, as a percentage, that team wins the match.
Input
The first line contains one integer: the number of data sets. Each data set is a single line with four integers , , , and , where and , and and are integer percentages (so ).
Output
For each data set, print on its own line the required probability as a percentage, rounded to exactly one digit after the decimal point.