USACO Silver February 2023 Prob 1 - Bakery Solution Concept

https://usaco.org/current/data/sol_prob1_silver_feb23.html

How does this line in the solution work:

if (b - a > 0):
lx = max(lx, (-c + b * d + (b - a - 1)) // (b - a))
I understand when b-a<0, but not this. why is b-a-1 added in the numerator?

it’s one way to do ceiling division: Is there a ceiling equivalent of // operator in Python? - Stack Overflow

1 Like