Candles from Stubs
You have N candles; burning one leaves a stub, and K stubs can be melted into one fresh candle (which also leaves a stub). How many candles can you burn in total?
Input: one line with two integers N and K.
Output: the total number of candles burned.
Constraints:
- 1 ≤ N ≤ 1018
- 2 ≤ K ≤ 109
Sample Tests
Input 1
10 3
Output 1
14
Input 2
1 2
Output 2
1
Discussion (opens after you solve — no spoilers before)
No comments yet.