CF1759D.Make It Round

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Inflation has occurred in Berlandia, so the store needs to change the price of goods.

The current price of good nn is given. It is allowed to increase the price of the good by kk times, with 1km1 \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.

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).

If there are several possible variants, output the one in which the new price is maximal.

If it is impossible to get a rounder price, output nmn \cdot m (that is, the maximum possible price).

输入格式

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

Each test case consists of one line.

This line contains two integers: nn and mm ( 1n,m1091 \le n, m \le 10^9 ). Where nn is the old price of the good, and the number mm means that you can increase the price nn no more than mm times.

输出格式

For each test case, output on a separate line the roundest integer of the form nkn \cdot k ( 1km1 \le k \le m , kk — an integer).

If there are several possible variants, output the one in which the new price (value nkn \cdot k ) is maximal.

If it is impossible to get a more rounded price, output nmn \cdot m (that is, the maximum possible price).

输入输出样例

  • 输入#1

    10
    6 11
    5 43
    13 5
    4 16
    10050 12345
    2 6
    4 30
    25 10
    2 81
    1 7

    输出#1

    60
    200
    65
    60
    120600000
    10
    100
    200
    100
    7

说明/提示

In the first case n=6n = 6 , m=11m = 11 . We cannot get a number with two zeros or more at the end, because we need to increase the price 5050 times, but 50>m=1150 > m = 11 . The maximum price multiple of 1010 would be 610=606 \cdot 10 = 60 .

In the second case n=5n = 5 , m=43m = 43 . The maximum price multiple of 100100 would be 540=2005 \cdot 40 = 200 .

In the third case, n=13n = 13 , m=5m = 5 . All possible new prices will not end in 00 , then you should output nm=65n \cdot m = 65 .

In the fourth case, you should increase the price 1515 times.

In the fifth case, increase the price 1200012000 times.

首页