Find the least number for which Proportion of Neutral Numbers is atleast n/m

By | February 21, 2017

Find the least number for which Proportion of Neutral Numbers is at least n/m


Increasing, Decreasing & Neutral Numbers

An increasing number is a number in which values of digits increase when we go from left to right; for example,123455 .

Similarly a decreasing number is a number in which values of digits decrease when we go from left to right; for example,54110 .

We shall call a positive integer that is neither increasing nor decreasing a “neutral” number; for example, 151212 .

The count of Neutral numbers increases and by the time we reach 21780 the proportion of neutral numbers >= 90%.

Find the least number for which the proportion of neutral numbers is at least n/m .


Explanation


Input Format

First line contains an integer denoting the number of test cases.

Each of the following lines contain two integers.

Constraints

1<=T<10^4

1<=n<m<=10^5

Output Format

For each of T test cases print one line containing a single integer – the answer to a problem.

Sample Input

2

1 2

90 100

Sample Output

538

21780

Time Limit:3.0 sec(s) for each input file.
Memory Limit:256 MB
Source Limit:1024 KB

SOURCE CODE : :

 

OUTPUT : :

 

Leave a Reply