Game of Cricket

1

1 votes
Medium
Problem

For those who don't know cricket, this 'could' be a lengthy problem.

In a game of cricket, at any ball, following events can occur with the following probability:

> no run - 20%
> one run - 25%
> two runs - 10%
> three runs - 2%
> four runs - 20%
> six runs - 10%
> wicket - 3%
> no ball - 5% (ball is not counted and one run is added)
> wide ball - 5% (same as no ball)

Given an instant of an One Day International match, can you calculate the probability of the chasing team to win? You will be given the overs completed, current score and number of wickets fallen, and target. You only need to output the integral part of the probability in percentage.

INPUT:

In the first line of each test file is given the number of test cases T, followed by T lines.

In each line will be four integers, denoting respectively overs completed(O), the current score(C), number of wickets fallen(W), and target score(S).

OUTPUT:

You need to output T lines, each containing the integer part of the probability of winning the match, in percentage.

CONSTRAINTS:

1<=T<=100000

0<=C<=S<=400

0<=W<=10

0.0<=Overs(O)<=50.0

(Overs will be a real number expressed as p.q where (0<=p<=49 && 0<=q<6) || (p=50 && q=0) or the overs may be a whole number)

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

In the first test case, we have one ball left in the match and 0 runs to make with 1 wicket in hand. This game is already won, so the probability is 100%.

In the second test case, we have one ball left with 1 runs to make and 1 wicket in hand. This can be done by making either one run, two runs, three runs, four runs, six runs, wide ball or no ball. This probability sums up to 77%.

Editor Image

?