Official
B - 水泳の練習 / Swimming Practice Editorial by admin
swe-2-highAfter \(x\) practice sessions, Takahashi can swim \(A + Bx\) meters. The answer is the smallest non-negative integer \(x\) satisfying \(A + Bx \geq C\), or \(0\) when \(A \geq C\) already. The program keeps adding b to a while a < c and counts the additions. Since \(B \geq 1\), the distance strictly increases each iteration, so the loop always terminates, and the count when a first reaches at least c is exactly the minimal \(x\). The number of iterations is at most \(\lceil \max(0, C - A) / B \rceil\), which is about \(10000\) under these constraints. The time complexity is \(O((C - A) / B)\) and the space used is \(O(1)\).