#P1150. Peter 的烟

Peter 的烟

Description

Peter has nn cigarettes. Each time he finishes a cigarette, he keeps the butt. kk (k>1k>1) butts can be exchanged for one new cigarette. How many cigarettes can Peter smoke in total?

Unlike some brain teasers, Peter cannot borrow cigarette butts from another dimension and return them after smoking.

Input Format

Each test case consists of one line containing two integers n,kn, k (1<n,k1081 < n, k \le 10^8).

Output Format

For each test case, output one line containing one integer, the total number of cigarettes.

4 3

5
10 3
14

Hint

For 100%100\% of the testdata, 1<n,k1081 < n, k \le 10^8.

Translated by ChatGPT 5