CF1759D.Make It Round
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Inflation has occurred in Berlandia, so the store needs to change the price of goods.
The current price of good n is given. It is allowed to increase the price of the good by k times, with 1≤k≤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 n⋅m (that is, the maximum possible price).
伯兰迪亚发生了通货膨胀,因此商店需要调整商品的价格。
商品 n 的当前价格已给出。允许将该商品的价格提高 k 倍,其中 1≤k≤m,且 k 为整数。请输出最“圆整”(即末尾零的个数最多)的新价格。
例如,数字 481000 比 1000010 更圆整(因为 481000 末尾有三个零,而 1000010 末尾仅有一个零)。
若存在多个满足最大末尾零个数的方案,请输出其中新价格最大者。
若无法得到比原价格更圆整的价格,则输出 n⋅m(即可能的最高价格)。
输入格式
The first line contains a single integer t (1≤t≤104) —the number of test cases in the test.
Each test case consists of one line.
This line contains two integers: n and m (1≤n,m≤109). 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.
第一行包含一个整数 t(1≤t≤104)——测试中测试用例的数量。
每个测试用例由一行组成。
该行包含两个整数:n 和 m(1≤n,m≤109)。其中 n 是商品的原价,而数字 m 表示你最多可以将价格 n 提高 m 次。
输出格式
For each test case, output on a separate line the roundest integer of the form n⋅k (1≤k≤m, k — an integer).
If there are several possible variants, output the one in which the new price (value n⋅k) is maximal.
If it is impossible to get a more rounded price, output n⋅m (that is, the maximum possible price).
对于每个测试用例,在单独一行中输出形如 n⋅k(其中 1≤k≤m,且 k 为整数)的最“圆整”的整数。
若存在多个可能的解,则输出其中新价格(即值 n⋅k)最大的那个。
若无法得到更圆整的价格,则输出 n⋅m(即可能的最大价格)。
输入输出样例
输入#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=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>m=11. The maximum price multiple of 10 would be 6⋅10=60.
In the second case n=5, m=43. The maximum price multiple of 100 would be 5⋅40=200.
In the third case, n=13, m=5. All possible new prices will not end in 0, then you should output n⋅m=65.
In the fourth case, you should increase the price 15 times.
In the fifth case, increase the price 12000 times.
第一种情况:n=6,m=11。我们无法得到末尾有两个或更多零的数,因为需要将价格提高 50 倍,但 50>m=11。最大的、是 10 的倍数的价格为 6⋅10=60。
第二种情况:n=5,m=43。最大的、是 100 的倍数的价格为 5⋅40=200。
第三种情况:n=13,m=5。所有可能的新价格均不会以 0 结尾,因此应输出 n⋅m=65。
第四种情况:应将价格提高 15 倍。
第五种情况:应将价格提高 12000 倍。
输入解题思路,AI测评打分。不知道怎么写?