SHARE
TWEET

Untitled

a guest Oct 17th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import math
  2. n, a, b, maxxm = map(int, input().split())
  3. l=0
  4. r=min(n, int(math.ceil(math.log(maxxm, b))) if b!=1 else (maxm+a-1)//a)+1
  5. while (r>1+l):
  6.     m=(l+r)//2
  7.     flag=0
  8.     if (b!=1):
  9.         flag=a*(b**m-1)//(b-1)
  10.     else:
  11.         flag=a*m
  12.     if (flag<=maxxm):
  13.         l = m
  14.     else:
  15.         r = m
  16. print(l)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top