1759D.md (2316B)
1 Source: https://codeforces.com/problemset/problem/1759/D 2 3 D. Make It Round 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 Inflation has occurred in Berlandia, so the store needs to change the price of goods. 22 23 The current price of good $n$ is given. It is allowed to increase the price of the good by $k$ times, with $1 \le k \le m$, k is an integer. Output the roundest possible new price of the good. That is, the one that has the maximum number of zeros at the end. 24 25 For example, the number 481000 is more round than the number 1000010 (three zeros at the end of 481000 and only one at the end of 1000010). 26 27 If there are several possible variants, output the one in which the new price is maximal. 28 29 If it is impossible to get a rounder price, output $n \cdot m$ (that is, the maximum possible price). 30 31 Input 32 33 The first line contains a single integer $t$ ($1 \le t \le 10^4$) —the number of test cases in the test. 34 35 Each test case consists of one line. 36 37 This line contains two integers: $n$ and $m$ ($1 \le n, m \le 10^9$). Where $n$ is the old price of the good, and the number $m$ means that you can increase the price $n$ no more than $m$ times. 38 39 Output 40 41 For each test case, output on a separate line the roundest integer of the form $n \cdot k$ ($1 \le k \le m$, $k$ — an integer). 42 43 If there are several possible variants, output the one in which the new price (value $n \cdot k$) is maximal. 44 45 If it is impossible to get a more rounded price, output $n \cdot m$ (that is, the maximum possible price). 46 47 Example 48 49 Input 50 51 ``` 52 10 53 54 6 11 55 56 5 43 57 58 13 5 59 60 4 16 61 62 10050 12345 63 64 2 6 65 66 4 30 67 68 25 10 69 70 2 81 71 72 1 7 73 ``` 74 75 Output 76 77 ``` 78 60 79 200 80 65 81 60 82 120600000 83 10 84 100 85 200 86 100 87 7 88 ``` 89 90 Note 91 92 In the first case $n = 6$, $m = 11$. We cannot get a number with two zeros or more at the end, because we need to increase the price $50$ times, but $50 \gt m = 11$. The maximum price multiple of $10$ would be $6 \cdot 10 = 60$. 93 94 In the second case $n = 5$, $m = 43$. The maximum price multiple of $100$ would be $5 \cdot 40 = 200$. 95 96 In the third case, $n = 13$, $m = 5$. All possible new prices will not end in $0$, then you should output $n \cdot m = 65$. 97 98 In the fourth case, you should increase the price $15$ times. 99 100 In the fifth case, increase the price $12000$ times.