Dice Rolls
Practice
2.6 (11 votes)
Easy Medium
Problem
46% Success 2607 Attempts 30 Points 3s Time Limit 256MB Memory 1024 KB Max Code
You have an unbiased dice which you want to keep rolling until you get N consecutive even numbers. You've rolled the dice M times and surprisingly, all rolls resulted in even numbers. What is the expected number of additional rolls needed until you get N consecutive even numbers?
Input:
The first line contains the number of cases T. Each of the next T lines contains two numbers N and M.
Output:
Output T lines containing the answer for the corresponding test case. Print the answer rounded to exactly 2 decimal places.
Constraints:
1 <= T <= 100
1 <= N <= 1000
0 <= M <= N
Submissions
Please login to view your submissions
Similar Problems
Points:30
Tags:
Easy-Medium
Editorial
No editorial available for this problem.