Expression Evaluation Error solution codeforces
On the board, Bob wrote base with sum (i. e. in decimal numeral system). Alice sees the board, but accidentally interprets the numbers on the board as base- integers and adds them up (in base ).positive integers in
What numbers should Bob write on the board, so Alice’s sum is as large as possible?
The input consists of multiple test cases. The first line contains an integer( ) — the number of test cases. The description of the test cases follows.
The only line of each test case contains two integersand ( ; ) — the sum and amount of numbers on the board, respectively. Numbers and are given in decimal notation (base ).
For each test case, outputpositive integers — the numbers Bob should write on the board, so Alice’s sum is as large as possible. If there are multiple answers, print any of them.
input Expression Evaluation Error solution codeforces
6 97 2 17 1 111 4 100 2 10 9 999999 3
70 27 17 3 4 100 4 10 90 1 1 2 1 1 1 1 1 1 999900 90 9
In the first test case,, and Alice’s sum is
(Hererepresents the number in base .) It can be shown that it is impossible for Alice to get a larger sum than .
In the second test case, Bob can only write a single number on the board, so he must write.
In the third test case,, and Alice’s sum is
It can be shown that it is impossible for Alice to get a larger sum than.
Also read : Airline Restrictions codechef solution