[Solution] Expected move CodeChef Solution | CodeChef Problem Solution 2022
You are given a fair coin and two integers and .
You repeatedly flip the coin and perform the following operation based on the result:
- If it lands on heads, then will increase by . However, if then will not change.
- If it lands on tails, will decrease by .
You stop as soon as the value of becomes .
Find the expected number of coin flips.
Note that it is guaranteed that under the given constraints, the answer is an integer and does not
Solution Click Below:- CLICK HERE
Input Format
- The first line contains a single integer — the number of test cases. Then the test cases follow.
- The first and only line of each test case contains two space separated integers and .
Output Format
For each testcase, output the expected number of coin flips.
No comments:
Post a Comment