codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

1765E.md (2309B)


      1 Source: https://codeforces.com/problemset/problem/1765/E
      2 
      3 E. Exchange
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 512 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 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.
     22 
     23 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).
     24 
     25 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.
     26 
     27 Input
     28 
     29 The first line contains one integer $t$ ($1 \le t \le 10^4$) — the number of test cases.
     30 
     31 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$).
     32 
     33 Output
     34 
     35 For each test case, print one integer — the minimum possible number of quests Monocarp has to complete.
     36 
     37 Example
     38 
     39 Input
     40 
     41 ```
     42 4
     43 
     44 100 25 30
     45 
     46 9999997 25 50
     47 
     48 52 50 48
     49 
     50 49 50 1
     51 ```
     52 
     53 Output
     54 
     55 ```
     56 4
     57 400000
     58 1
     59 1
     60 ```
     61 
     62 Note
     63 
     64 In the first test case of the example, Monocarp should complete $4$ quests, and then sell $4$ gold coins for $100$ silver coins.
     65 
     66 In the second test case, Monocarp should complete $400000$ quests, and then sell $400000$ gold coins for $10$ million silver coins.
     67 
     68 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.
     69 
     70 In the fourth test case, Monocarp should complete $1$ quest and then sell the gold coin he has obtained for $50$ silver coins.