Given a number X and another number Y . There are a total N cycles , and alternatively we perform operation on each number . In each cycle , we multiply the number by 2 . Starting with X .
Suppose after all the N cycles, the number X has become W and number Y has become Z . You have to calculate the division of the maximum number among W and Z by the minimum number among W and Z .
The first line of the input contains an integer T denoting the number of test cases. The description of each testcase follows. Each test case contains a single line with 3 integers X , Y , and N .
For each test case output a new line with a single integer which should be the answer.
1 ≤ T ≤ 100
1 ≤ X ≤ 107
1 ≤ Y ≤ 107
1 ≤ N ≤ 107
1 2 1
3 2 3
In the second testcase, the initial numbers are (X = 3, Y = 2) . There three turns. In the first cycle X is multiplied by 2 . So, we get ( X = 6, Y = 2 ) . In the second cycle Y ( Y = 2) multiplies his number by 2. Hence, we get ( X = 6, Y = 4 ) . In the third cycle X ( X = 6) is multiplied by 2. So, we get (X = 12, Y = 4) . As N = 3 , and we are completed with 3 cyles , therefore W = 12, and Z = 4 .
max ( W , Z ) / min ( W , Z ) = 12 / 4 = 3. Hence the second output is 3.
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.