Advertisement
Guest User

Emrakul

a guest
Oct 7th, 2015
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. import sys
  2.  
  3. def power2(num):
  4.     counter = 0
  5.     while num > 1:
  6.         counter += 1
  7.         num = num // 2
  8.     return counter
  9.  
  10. N = int(input())
  11. first = int(input())
  12. second = int(input())
  13. if first < second:
  14.     second, first = first, second
  15. diff = power2(first) - power2(second)
  16. if diff > 0:
  17.     for i in range(diff):
  18.         first = first // 2
  19. while True:
  20.     if first == second:
  21.         print(first)
  22.         sys.exit()    
  23.     first = first // 2
  24.     second = second // 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement