309962: CF1765E. Exchange

Memory Limit:512 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Exchange

题意翻译

你需要通过完成探险来争取至少 $n$ 个银币,遗憾的是,你手头上现在一个币也没有。 完成一次探险后,你可以挣取 1 个金币。你可以随时且不限次数地进行以下交易: + 使用 1 个金币,买入 $a$ 个银币; + 使用 $b$ 个银币,买入 1 个金币。 一共 $ t $ ( $ 1 \le t \le 10^4 $ ) 组数据。每组数据给出 $n,a,b$ ( $ 1 \le n \le 10^7 $ ; $ 1 \le a, b \le 50 $ )。输出你需要完成的最少探险次数。 **有多测。**

题目描述

Monocarp is playing a MMORPG. There are two commonly used types of currency in this MMORPG — gold coins and silver coins. Monocarp wants to buy a new weapon for his character, and that weapon costs $ n $ silver coins. Unfortunately, right now, Monocarp has no coins at all. Monocarp can earn gold coins by completing quests in the game. Each quest yields exactly one gold coin. Monocarp can also exchange coins via the in-game trading system. Monocarp has spent days analyzing the in-game economy; he came to the following conclusion: it is possible to sell one gold coin for $ a $ silver coins (i. e. Monocarp can lose one gold coin to gain $ a $ silver coins), or buy one gold coin for $ b $ silver coins (i. e. Monocarp can lose $ b $ silver coins to gain one gold coin). Now Monocarp wants to calculate the minimum number of quests that he has to complete in order to have at least $ n $ silver coins after some abuse of the in-game economy. Note that Monocarp can perform exchanges of both types (selling and buying gold coins for silver coins) any number of times.

输入输出格式

输入格式


The first line contains one integer $ t $ ( $ 1 \le t \le 10^4 $ ) — the number of test cases. Each test case consists of one line containing three integers $ n $ , $ a $ and $ b $ ( $ 1 \le n \le 10^7 $ ; $ 1 \le a, b \le 50 $ ).

输出格式


For each test case, print one integer — the minimum possible number of quests Monocarp has to complete.

输入输出样例

输入样例 #1

4
100 25 30
9999997 25 50
52 50 48
49 50 1

输出样例 #1

4
400000
1
1

说明

In the first test case of the example, Monocarp should complete $ 4 $ quests, and then sell $ 4 $ gold coins for $ 100 $ silver coins. In the second test case, Monocarp should complete $ 400000 $ quests, and then sell $ 400000 $ gold coins for $ 10 $ million silver coins. In the third test case, Monocarp should complete $ 1 $ quest, sell the gold coin for $ 50 $ silver coins, buy a gold coin for $ 48 $ silver coins, and then sell it again for $ 50 $ coins. So, he will have $ 52 $ silver coins. In the fourth test case, Monocarp should complete $ 1 $ quest and then sell the gold coin he has obtained for $ 50 $ silver coins.

Input

题意翻译

你需要通过完成探险来争取至少 $n$ 个银币,遗憾的是,你手头上现在一个币也没有。 完成一次探险后,你可以挣取 1 个金币。你可以随时且不限次数地进行以下交易: + 使用 1 个金币,买入 $a$ 个银币; + 使用 $b$ 个银币,买入 1 个金币。 一共 $ t $ ( $ 1 \le t \le 10^4 $ ) 组数据。每组数据给出 $n,a,b$ ( $ 1 \le n \le 10^7 $ ; $ 1 \le a, b \le 50 $ )。输出你需要完成的最少探险次数。 **有多测。**

Output

**题意翻译**

你需要通过完成探险来赚取至少 $ n $ 个银币,但你手头上现在一个币也没有。每次完成一次探险,你可以获得 1 个金币。你可以随时且不限次数地进行以下交易:

+ 使用 1 个金币,买入 $ a $ 个银币;
+ 使用 $ b $ 个银币,买入 1 个金币。

共有 $ t $ 组数据($ 1 \le t \le 10^4 $)。每组数据给出 $ n, a, b $($ 1 \le n \le 10^7 $;$ 1 \le a, b \le 50 $)。输出你需要完成的最少探险次数。

**有多测。**

**题目描述**

Monocarp 在玩一个 MMORPG 游戏。在这个游戏中,有两种常用的货币——金币和银币。Monocarp 想为他的人物买一把新武器,这把武器需要 $ n $ 个银币。但目前,Monocarp 一个币也没有。

Monocarp 可以通过完成游戏中的任务来赚取金币。每个任务可以获得恰好 1 个金币。Monocarp 也可以通过游戏内的交易系统来交换货币。Monocarp 花了几天时间分析游戏内的经济系统,他得出了以下结论:可以用 1 个金币卖出 $ a $ 个银币(即 Monocarp 可以失去 1 个金币来获得 $ a $ 个银币),或者用 $ b $ 个银币买入 1 个金币(即 Monocarp 可以失去 $ b $ 个银币来获得 1 个金币)。

现在 Monocarp 想要计算他至少需要完成多少任务,以便在滥用游戏内经济系统后拥有至少 $ n $ 个银币。注意,Monocarp 可以进行任意次数的两种类型的交换(卖出和买入金币换银币)。

**输入输出格式**

**输入格式**

第一行包含一个整数 $ t $($ 1 \le t \le 10^4 $)——测试用例的数量。

每个测试用例包含一行,其中包含三个整数 $ n, a, b $($ 1 \le n \le 10^7 $;$ 1 \le a, b \le 50 $)。

**输出格式**

对于每个测试用例,打印一个整数——Monocarp 需要完成的最少任务数。

**输入输出样例**

**输入样例 #1**

```
4
100 25 30
9999997 25 50
52 50 48
49 50 1
```

**输出样例 #1**

```
4
400000
1
1
```

**说明**

在第一个测试用例中,Monocarp 应该完成 4 个任务,然后用 4 个金币换取 100 个银币。

在第二个测试用例中,Monocarp 应该完成 400000 个任务,然后用 400000 个金币换取 1000 万个银币。

在第三个测试用例中,Monocarp 应该完成 1 个任务,卖出那枚金币换取 50 个银币,然后用 48 个银币买入 1 个金币,再次卖出换取 50 个银币。这样,他将拥有 52 个银币。

在第四个测试用例中,Monocarp 应该完成 1 个任务,然后卖出他获得的那枚金币换取 50 个银币。**题意翻译** 你需要通过完成探险来赚取至少 $ n $ 个银币,但你手头上现在一个币也没有。每次完成一次探险,你可以获得 1 个金币。你可以随时且不限次数地进行以下交易: + 使用 1 个金币,买入 $ a $ 个银币; + 使用 $ b $ 个银币,买入 1 个金币。 共有 $ t $ 组数据($ 1 \le t \le 10^4 $)。每组数据给出 $ n, a, b $($ 1 \le n \le 10^7 $;$ 1 \le a, b \le 50 $)。输出你需要完成的最少探险次数。 **有多测。** **题目描述** Monocarp 在玩一个 MMORPG 游戏。在这个游戏中,有两种常用的货币——金币和银币。Monocarp 想为他的人物买一把新武器,这把武器需要 $ n $ 个银币。但目前,Monocarp 一个币也没有。 Monocarp 可以通过完成游戏中的任务来赚取金币。每个任务可以获得恰好 1 个金币。Monocarp 也可以通过游戏内的交易系统来交换货币。Monocarp 花了几天时间分析游戏内的经济系统,他得出了以下结论:可以用 1 个金币卖出 $ a $ 个银币(即 Monocarp 可以失去 1 个金币来获得 $ a $ 个银币),或者用 $ b $ 个银币买入 1 个金币(即 Monocarp 可以失去 $ b $ 个银币来获得 1 个金币)。 现在 Monocarp 想要计算他至少需要完成多少任务,以便在滥用游戏内经济系统后拥有至少 $ n $ 个银币。注意,Monocarp 可以进行任意次数的两种类型的交换(卖出和买入金币换银币)。 **输入输出格式** **输入格式** 第一行包含一个整数 $ t $($ 1 \le t \le 10^4 $)——测试用例的数量。 每个测试用例包含一行,其中包含三个整数 $ n, a, b $($ 1 \le n \le 10^7 $;$ 1 \le a, b \le 50 $)。 **输出格式** 对于每个测试用例,打印一个整数——Monocarp 需要完成的最少任务数。 **输入输出样例** **输入样例 #1** ``` 4 100 25 30 9999997 25 50 52 50 48 49 50 1 ``` **输出样例 #1** ``` 4 400000 1 1 ``` **说明** 在第一个测试用例中,Monocarp 应该完成 4 个任务,然后用 4 个金币换取 100 个银币。 在第二个测试用例中,Monocarp 应该完成 400000 个任务,然后用 400000 个金币换取 1000 万个银币。 在第三个测试用例中,Monocarp 应该完成 1 个任务,卖出那枚金币换取 50 个银币,然后用 48 个银币买入 1 个金币,再次卖出换取 50 个银币。这样,他将拥有 52 个银币。 在第四个测试用例中,Monocarp 应该完成 1 个任务,然后卖出他获得的那枚金币换取 50 个银币。

加入题单

算法标签: