You have a jumpy ball. You throw it up from the ground upto a height of H. The ball is jumpy, so when it comes back to the ground, it rebounds and goes up again to a distance of floor(H/2). This keeps on repeating till it can't rebound anymore. You need to find the total distance travelled by the ball.
The first line of the input contains a single integer T, denoting the number of test cases. Then T test case follows. Each testcase contains a single line having H as input.
For each testcase, print the total distance travelled.
For testcase 1: H is 10. From ground to H it travels d=10. From H to ground it travels d=10+10. Now H becomes floor(10/2). So ball rebounds to d=10+10+5. It goes down to ground. d=10+10+5+5. Now H becomes floor(5/2). So ball rebounds to d=10+10+5+5+2. The ball goes down. d=10+10+5+5+2+2. H becomes floor(2/2). So ball rebounds to d=10+10+5+5+2+2+1. It goes down to ground. d=10+10+5+5+2+2+1+1. H becomes floor(1/2). H is zero so no rebound. total d=36.
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.