RUN Number
Time limit1sMemory limit1024 MB
Given an N-digit number K, write K as a sum of at most N+1 RUN numbers (repdigits) and print the terms.
- Level
Medium5 of 10
- Topics
- Math, Implementation, Greedy
- Solved
- No attempts yet
Problem
A positive integer is called a RUN number if all of its digits are the same digit. For example, , , and are RUN numbers, but , , and are not.
Given an -digit number , express as a sum of at most RUN numbers. It can be proven that this is always possible.
Input
The first line contains the number of test cases .
Each test case consists of one line with two integers and , separated by a space.
Output
For each test case, print the following.
- On the first line, print the number of RUN numbers whose sum is ().
- On the second line, print the RUN numbers separated by spaces. If multiple answers exist, print any of them.
Constraints
- . That is, is an -digit number.