By ACM International Collegiate Programming Contest, Kuwait University United Arab Emirates
Consider the following function:
Given a pair of values <V,K>, write a program to determine if there are values for a, b, and k satisfying all of the following:
0 < a ≤ b < 10
0 ≤ k ≤ K
f k (a,b) = V
Your program will be given a series of pairs <V ,K>, each pair on a separate line. Note that 0 ≤ V < 1,000, 000.
The end of the input file is identified by a dummy pair (which is not part of the test cases) where both V and K are 0.
For each given pair <V ,K>, if there are values for a, b,and k satisfying the requirements, write on a separate line, the following output:
If there is more than one solution, print the solution with the smallest value of k within all the solutions with the smallest value of b within all the solutions with the smallest value of a. (In other words, the first solution if they were sorted lexicographically in an ascending order using the key <a,b,k>.)
If there is no solution, print the following:
"no solution for <V,K>"
|Input Sample||Output Sample|