Advertisement
PlotnikovPhilipp

Untitled

Oct 24th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.32 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. n, k = [int(i) for i in input().split()]
  3. gamed = 1
  4. res = n - 1
  5. t = 0
  6. while res > 0:
  7.     if gamed >= k and k <= res:
  8.         gk = res // k
  9.         res %= k
  10.         gamed += gk*k
  11.         t += gk
  12.         continue
  13.     g = min(gamed, k, res)
  14.     gamed += g
  15.     res -= g
  16.     t += 1
  17. print(t)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement