Advertisement
Guest User

C

a guest
Oct 17th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.30 KB | None | 0 0
  1. import math
  2. n,a,b,m = [int(i) for i in input().split()]
  3. c = 0
  4. if b != 1:
  5.     try:
  6.         c = math.floor(math.log((m*(b-1)+a)/a, b))
  7.         #print('a')
  8.     except OverflowError:
  9.         #print('b')
  10.         c = math.floor(math.log((m*(b-1)+a)//a, b))
  11. else:
  12.     c = m//a
  13. if c > n:
  14.     c = n
  15. print(c)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement