The Cycle Game
Submissions: 816   Accuracy:

51.94%

  Difficulty: Basic   Marks: 1

Given a number X and another number . 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 . You have to calculate the division of the maximum number among and Z by the minimum number among W and.

Input:
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 , , and .

Output:
For each test case output a new line with a single integer which should be the answer.

Constraints:
1 ≤ T ≤ 100
1 ≤ X ≤ 107
1 ≤ Y ≤ 107
1 ≤ N ≤ 107

Example:  
Input:

2
1 2 1
3 2 3
Output:
1
3

Explanation:
In the first testcase ( only one cycle ), the initial numbers are ( X = 1, Y = 2). There is only one turn. In this turn X is multiplied by 2. Hence, we get (X = 2, Y = 2). Therefore W = 2, and Z = 2 . max ( , ) / min ( ,  ) =  2 / 2  = 1. Hence the first output is 1.

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 ( ,  ) / min ( , ) = 12 / 4 = 3. Hence the second output is 3.

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Diksha Singhal
Author: diksha1812


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.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.