We Are Discuss About CODECHEF SOLUTION

MinAdd Codechef Solution

MinAdd Codechef Solution

Answers will be Uploaded Shortly and it will be Notified on Telegram, So JOIN NOW
JoinScishowEngineerTelegram

Problem

Chef loves problems about digits and he came up with an interesting one.

Chef has given you two integers � and �. You should find the minimum non-negative integer �, such that �+� has at most � distinct digits in its decimal representation.

For example, 1231 has three distinct digits and 100 has two distinct digits.

Input Format

  • The first line of input will contain a single integer �, denoting the number of test cases.
  • The first and only line of each test case consists of two space-separated integers � and �, as described in the problem statement.

Output Format

For each test case, output on a new line the minimum non-negative integer � which satisfies the problem conditions.

Constraints

  • 1≤�≤105
  • 1≤�≤109
  • 1≤�≤10

Sample 1:

Input

Output

9
30 1
56 4
364 2
125 3
37662730 3
41872528 4
73170084 8
90032975 1
7487471 3
3
0
2
0
603
1583
0
9967024
3

Explanation:

Test case 1: 30 has 2 distinct digits which is more than 1, so we should add 3 to 30 to make it equal to 33 which has only 1 distinct digit.

Answers will be Uploaded Shortly and it will be Notified on Telegram, So JOIN NOW
JoinScishowEngineerTelegram

 

SOLUTION

Here Discuss About MinAdd Codechef Solution

SOLUTION

MinAdd Codechef Solution

SOLUTION

Yhaa You have done it but next? if YOU Want to Get Others Please Visit Here ScishowEngineer   Then Follow US HERE and Join Telegram.

If You Want To Learn Something New Then Visit Our Official Channel YOUTUBE

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *