Avid Cricketer

4.5

6 votes
Easy
Problem

Statement :

Utkarsh and Debanjan are avid cricket and video game fans. They have recently purchased a new game , "Don Bradman Cricket 14". Debanjan challenges Utkarsh to play India vs Australia, and to defeat Australia in Legend Mode. Utkarsh has accepted the challenge and now faces a task to score "R" runs from "B" balls. Can you tell us the probability of Utkarsh winning the match if :

  1. Every event is equiprobable.

  2. The events are : {W,0,1,2,3,4,6}.

Note : Assume you have infinite wickets!

Input format:

First line contains T , the number of test cases. Each of the next T lines contains "R" , the number of runs required and "B" , the number of balls left.

Output format:

For every test case T , print the expected number of runs scored. Output should have exactly 6 decimal place precision.

Constraints:

1<=T<=10

1<=R<=1000

1<=B<=1000

Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

Case 1 : On the very first ball , he can score W , 0 , 1 , 2 , 3 , 4 , 6 with equal probability.

Case 2 : There are only 4 events that support a victory!

Editor Image

?