Leaderboard
Showing:
The Cycle Game
Basic Accuracy: 0.0% Submissions: 0 Points: 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 . Find the integer division of the maximum number among and Z by the minimum number among W and.
 

Example 1:

Input: x = 1, y = 2, n = 1
Output: 2
Explanation:  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 (Z) / min (Z) =  2 / 2  = 1. 
Hence the first output is 1.

Example 2:

Input: x = 3, y = 2, n = 3
Output: 3
Explanation: 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 , 
completed with 3 cyles, therefore W = 12 and 
Z = 4. max (,  Z) / min (Z) = 12 / 4 = 3. 
Hence the second output is 3. 

 

Your Task:
You don't need to read or print anyhting. Your task is to complete the function find_division() which takes X, Y and N as input parameter and returns the integer division of max(w, z) / min(w, z)

 

Expected Time Complexity: O(1)
Expected Space Complexity: O(1)

 

Constraints:
1 <= X, Y <= 108
1 <= N <= 109

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

The Cycle Game

Output Window