Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- n,a,b,m = [int(i) for i in input().split()]
- c = 0
- if b != 1:
- try:
- c = math.floor(math.log((m*(b-1)+a)/a, b))
- #print('a')
- except OverflowError:
- #print('b')
- c = math.floor(math.log((m*(b-1)+a)//a, b))
- else:
- c = m//a
- if c > n:
- c = n
- print(c)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement