Under construction

Still being built. Things may change

Winning the Match

Time limit1sMemory limit128 MB

Summary
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, AA and BB. Under the rules below, compute the probability that team AA wins the match.

  • The match is played by two teams, AA and BB.
  • The first team to win KK 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 LL points wins the game.
  • When team AA serves in a round, it wins that round with probability Pa%Pa\% (and loses it with probability (100−Pa)%(100 - Pa)\%).
  • When team BB serves in a round, it wins that round with probability Pb%Pb\% (and loses it with probability (100−Pb)%(100 - Pb)\%).
  • 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 PaPa, PbPb, KK, and LL, compute the probability, as a percentage, that team AA 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 PaPa, PbPb, KK, and LL, where 1≤K≤1001 \le K \le 100 and 1≤L≤1001 \le L \le 100, and PaPa and PbPb are integer percentages (so 0≤Pa,Pb≤1000 \le Pa, Pb \le 100).

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.

Examples1

  1. Example 1

    Input
    2
    100 50 1 3
    100 1 1 1
    
    Expected output
    93.8
    99.5