Contents
The One On The Last Night solution codechef

For Solution
Click Here!
Chandler wants to give Joey money as Joey is going through some financial struggles. He believes $1500 will be enough to pay off the bills. Chandler makes up a game on the spot called “Cups”, which has no rules. Every move Joey makes in the “game”, Chandler says that he wins a lot of money. Joey, being “smart”, finds this out and thus wants to set some rules.
Joey and Chandler have a set of cards, where the value of a card is defined as the product of all the digits of the number printed on that card.
For example, value of the card with the number 77 equals 77, value of the card with the number 203203 equals 2⋅0⋅3=02⋅0⋅3=0.
The initial number on Joey’s card is NN (without any leading zeroes). Chandler can make at most KK changes on the digits of the number before it gets noticed. In one change, he can choose any digit xx (x≠9x≠9) of the number printed on card and replace it with x+1x+1. Find the maximum possible value of Joey’s card after making the changes.
The One On The Last Night solution codechef Input Format
 First line will contain TT, number of testcases. Then the testcases follow.
 For each test case, given two integer NN and KK, denoting the initial number on Joey’s card and the number of changes Chandler can make.
Output Format
For each testcase, output in a single line the maximum possible value of Joey’s card after making the changes.
Constraints The One On The Last Night solution codechef
 1≤T≤1031≤T≤103
 1≤N≤1061≤N≤106
 0≤K≤1060≤K≤106
Sample Input 1
3
1 5
2221 3
123456 0
The One On The Last Night solution codechef Sample Output 1
6
36
720
Explanation
Test case 1: Chandler can increase the digit 11 five times to make the final number on card 66.
Test case 2: Chandler can increase the first digit of the given number once and the last digit twice. After making these changes, the final number on the card would be 32233223, whose value is equal to 3636. There are other ways to make changes on the printed number which may lead to one of the following numbers being the resulting number on card : 22332233, 23232323, 23322332, 32323232, 33223322; note that all these numbers have their values equal to 3636 as well.

For Solution
Click Here!