EPIC Institute of Technology Round Summer 2024 (Div. 1 + Div. 2)
A
Upload More RAM
Codeforces
800
原题
←B →
翻译中…

Oh no, the ForceCodes servers are running out of memory! Luckily, you can help them out by uploading some of your RAM!

翻译中…

You want to upload $n$ GBs of RAM. Every second, you will upload either $0$ or $1$ GB of RAM. However, there is a restriction on your network speed: in any $k$ consecutive seconds, you can upload only at most $1$ GB of RAM in total.

翻译中…

Find the minimum number of seconds needed to upload $n$ GBs of RAM!

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line of input contains a single integer $t$ ($1 \le t \le 10^4$) — the number of test cases. The description of the test cases follows.

翻译中…

The first and only line of each test case contains two integers $n$ and $k$ ($1 \le n, k \le 100$) — the number of GBs that you want to upload and the length of the time window respectively.

翻译中…

Output

翻译中…

For each test case, output a single integer — the minimum number of seconds needed to upload $n$ GBs of RAM.

翻译中…

Note

翻译中…

In the first test case, you can upload $1$ GB of RAM per second, so to upload $5$ GBs, you need $5$ seconds.

翻译中…

In the second test case, you can upload $1$ GB in the first second, $0$ GBs in the second second, and $1$ GB in the third second, which in total adds up to exactly $2$ GBs of uploaded RAM.

翻译中…

In the third test case, you can upload $1$ GB in the first second, $0$ GBs in the second second, $0$ GBs in the third second, and $1$ GB in the fourth second, which in total adds up to exactly $2$ GBs of uploaded RAM.

翻译中…

样例

Input #1
6
5 1
2 2
2 3
1 7
11 5
100 100
Output #1
5
3
4
1
51
9901
InputCopy OutputCopy
题目信息
题号
1987A
时间限制
1 s
内存限制
256 MB
标签
贪心
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。