Advertisement
serega1112

Olympiad

Jan 16th, 2022
918
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. total = int(input())
  2. first = int(input())
  3.  
  4. if not total:
  5.     print(0)
  6. elif total <= first:
  7.     print(1)
  8. else:
  9.     l = 1
  10.     r = total + 1
  11.  
  12.     while r - l > 1:
  13.         mid = l + (r - l) // 2
  14.         summ = 0.5 * mid * (mid - 1) + mid * first
  15.         if summ < total:
  16.             l = mid
  17.         else:
  18.             r = mid
  19.     print(r)
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement