CF1765E.Exchange

入门

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 nn 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 aa silver coins (i. e. Monocarp can lose one gold coin to gain aa silver coins), or buy one gold coin for bb silver coins (i. e. Monocarp can lose bb 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 nn 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.

Monocarp 正在玩一款大型多人在线角色扮演游戏(MMORPG)。该游戏中有两种常用货币——金币和银币。Monocarp 想为自己的角色购买一件新武器,该武器售价为 nn 枚银币。不幸的是,此时 Monocarp 手中一枚硬币也没有。

Monocarp 可以通过完成游戏中的任务来获取金币,每项任务恰好奖励一枚金币。Monocarp 还可以通过游戏内的交易系统进行货币兑换。Monocarp 已花费数日分析游戏内经济系统,并得出如下结论:他可以将一枚金币卖出,换取 aa 枚银币(即 Monocarp 放弃一枚金币,获得 aa 枚银币),也可以用 bb 枚银币购买一枚金币(即 Monocarp 放弃 bb 枚银币,获得一枚金币)。

现在,Monocarp 想计算:为了在充分利用游戏内经济系统后,最终至少拥有 nn 枚银币,他最少需要完成多少项任务?注意,Monocarp 可以任意多次执行两种类型的兑换操作(即出售金币换银币、或用银币购买金币)。

输入格式

The first line contains one integer tt (1≤t≤1041 \le t \le 10^4) — the number of test cases.

Each test case consists of one line containing three integers nn, aa and bb (1≤n≤1071 \le n \le 10^7; 1≤a,b≤501 \le a, b \le 50).

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

每个测试用例由一行组成,包含三个整数 nn、aa 和 bb(1≤n≤1071 \le n \le 10^7;1≤a,b≤501 \le a, b \le 50)。

输出格式

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

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

输入输出样例

  • 输入#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 44 quests, and then sell 44 gold coins for 100100 silver coins.

In the second test case, Monocarp should complete 400000400000 quests, and then sell 400000400000 gold coins for 1010 million silver coins.

In the third test case, Monocarp should complete 11 quest, sell the gold coin for 5050 silver coins, buy a gold coin for 4848 silver coins, and then sell it again for 5050 coins. So, he will have 5252 silver coins.

In the fourth test case, Monocarp should complete 11 quest and then sell the gold coin he has obtained for 5050 silver coins.

在示例的第一个测试用例中,Monocarp 应完成 44 个任务,然后将 44 枚金币出售,换取 100100 枚银币。

在第二个测试用例中,Monocarp 应完成 400000400000 个任务,然后将 400000400000 枚金币出售,换取 10001000 万枚银币。

在第三个测试用例中,Monocarp 应完成 11 个任务,将获得的金币以 5050 枚银币的价格售出,再以 4848 枚银币的价格购回一枚金币,最后再次以 5050 枚银币的价格售出。因此,他最终将拥有 5252 枚银币。

在第四个测试用例中,Monocarp 应完成 11 个任务,然后将获得的金币以 5050 枚银币的价格售出。

输入解题思路,AI测评打分。不知道怎么写?

首页