Fun with Probability

4.2

11 votes
Medium-Hard
Problem

In the pradnya world,Passengers use bus as a public transport.
There is a straight road which has bus stops named B0 , B1 , B2 , B3..... up to Bn after each mile.
The "BIG BOSS" is at B0 and wants to reach the final stop.

The bus through which the BIG BOSS is travelling initially has an energy value 'E' at B0 and a damage value 'D'.
There can be three cases between two consecutive bus stops:
case 1: low traffic on the road.
In this case, The bus will reduce its energy value by 2
case 2: medium traffic on the road.
In this case, The bus will reduce its energy value by 5
case 3: high traffic on the road.
In this case, The bus will reduce its energy value by 10


There can be two possibilities between two consecutive bus stops:

Possibility 1:
There is a hurdle between two consecutive bus stops.
In this situation, The bus decreases its damage value by 1 and decreases its energy value by 20.

Possibility 2:
There is no hurdle between two consecutive bus stops.

In this situation, No extra damage will be done and no extra energy will be consumed

The BIG BOSS can reach the bus stop Bn if and only if the energy value and the damage value of the bus at Bn is not negative.
Help the BIG BOSS to determine the probability of reaching Bn.

Note: There are equal probabilities for every possibility and cases

INPUT FORMAT:
The first line contains the number of test cases t.
The first line of each test case contains 3 space separated integers n, E and D.
where n denotes the last bus stop(Bn),
E denotes the energy value of the bus at B0,
D denotes the damage value of the bus at B0

OUTPUT FORMAT:
For each test case, output an integer denoting the probability percent on each line.


CONSTRAINTS:
1 <= T <= 1000
0 <= n <= 100
0 <= E <= 500
0 <= D <= 50a

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

In the 1st test case, since the energy is zero, probability is 0

In the 2nd test case, the bus can reach the final bus stop if there is no hurdle, else the bus cannot reach.
Hence the probability of reaching is 1/2.
Hence the probability percent is 50

In the 3rd test case, there are 6 possibilities:
1st possibility: There is no hurdle and low traffic between B0 and B1
In this case, the energy value at B1 will be (22-2)=20. Thus the bus will reach B1

2nd possibility: There is no hurdle and medium traffic between B0 and B1
In this case, the energy value at B1 will be (22-5)=18. Thus the bus will reach B1

3rd possibility: There is no hurdle and high traffic between B0 and B1
In this case, the energy value at B1 will be (22-10)=12. Thus the bus will reach B1

4th possibility: There is a hurdle and low traffic between B0 and B1
In this case, the energy value at B1 will be (22-20-2)=0. The Damage value at B1 will be (10-1)=9. Thus the bus will reach B1

5th possibility: There is a hurdle and medium traffic between B0 and B1
In this case, the energy value at B1 will be (22-20-5)=-3. Thus the bus will not reach B1

6th possibility: There is a hurdle and high traffic between B0 and B1
In this case, the energy value at B1 will be (22-20-10)=-8. Thus the bus will not reach B1

So, out of 6 possibilities, in 4 possibilities, the bus reaches B1.
Thus, the probability is (4/6) = 66.66%
So, the integer probability percent is 66

Editor Image

?