远端评测题 1000ms 125MiB

Peter 的糖

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Background

Warm reminder: Smoking is harmful to your health; please do not attempt to smoke!

Problem 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

第 24 课:模拟算法

未认领
状态
已结束
题目
15
开始时间
2026-7-6 22:00
截止时间
2026-7-13 22:00
可延期
24 小时