Thursday, 2 December 2021

Bear and Big Brother Problem !!!

 PROBLEM 30: Bear and Big Brother


Problem Reference : Codeforces


Bear Limak wants to become the largest of bears, or at least to become larger than his brother Bob.

Right now, Limak and Bob weigh a and b respectively. It's guaranteed that Limak's weight is smaller than or equal to his brother's weight.

Limak eats a lot and his weight is tripled after every year, while Bob's weight is doubled after every year.

After how many full years will Limak become strictly larger (strictly heavier) than Bob?


Input:

The only line of the input contains two integers a and b (1 ≤ a ≤ b ≤ 10) — the weight of Limak and the weight of Bob respectively.

Output:

Print one integer, denoting the integer number of years after which Limak will become strictly larger than Bob.


Solution: 


  1. a,b = input().split()
  2. k = int(a)
  3. k1 = int(b)
  4. k2 = 0
  5. for i in range(0,10):
  6. k = k * 3
  7. k1 = k1 * 2
  8. k2+=1
  9. if k > k1 :
  10. break
  11. print(k2)


The above solution is in python language.



Examples
input
4 7
output
2
input
4 9
output
3
input
1 1
output
1

No comments:

Post a Comment

Rearrange an array with O(1) extra space

  PROBLEM 61:  Rearrange an array with O(1) extra space (For best view experience, view in windows version) Problem Reference : GeeksForGeek...