CF1884A.Simple Design

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

A positive integer is called kk -beautiful, if the digit sum of the decimal representation of this number is divisible by kk^{\dagger} . For example, 92729272 is 55 -beautiful, since the digit sum of 92729272 is 9+2+7+2=209 + 2 + 7 + 2 = 20 .

You are given two integers xx and kk . Please find the smallest integer yxy \ge x which is kk -beautiful.

^{\dagger} An integer nn is divisible by kk if there exists an integer mm such that n=kmn = k \cdot m .

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt ( 1t1041 \le t \le 10^4 ). The description of the test cases follows.

The only line of each test case contains two integers xx and kk ( 1x1091 \le x \le 10^9 , 1k101 \le k \le 10 ).

输出格式

For each test case, output the smallest integer yxy \ge x which is kk -beautiful.

输入输出样例

  • 输入#1

    6
    1 5
    10 8
    37 9
    777 3
    1235 10
    1 10

    输出#1

    5
    17
    45
    777
    1243
    19

说明/提示

In the first test case, numbers from 11 to 44 consist of a single digit, thus the digit sum is equal to the number itself. None of the integers from 11 to 44 are divisible by 55 .

In the fourth test case, the digit sum of 777777 is 7+7+7=217 + 7 + 7 = 21 which is already divisible by 33 .

首页