CF1765E.Exchange

普及/提高-

通过率:0%

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.

输入格式

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

Each test case consists of one line containing three integers nn , aa and bb ( 1n1071 \le n \le 10^7 ; 1a,b501 \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 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.

首页