Hardware
Time limit1sMemory limit128 MB
Expand each house-number order into individual numbers, count how many times each digit 0-9 appears, and print the per-digit totals plus the grand total.
- Level
Easy3 of 10
- Topics
- Simulation, Implementation, Math
- Solved
- No attempts yet
Problem
Ola Clason's hardware store is an old company where most of the work is still done the old-fashioned way. Among other things, the company is the one and only supplier of marble house numbers. These house numbers have become extremely popular with construction companies, especially those building luxury estates. This is great for Ola Clason, but it also creates a small problem: Nisse, who manages the incoming orders, has become a bottleneck in the business.
Most orders look like "Coconut Drive 200, 202, 204, ..., 220", which means every even number between 200 and 220. Nisse's job is to convert such an order into a list of the individual digits (and other symbols) that must be produced.
Your task is to write a program that automates Nisse's work for orders that contain only positive integer house numbers. Nisse will keep handling all special orders (those that include non-digit symbols) by hand.
Input
The first line of input contains a single positive integer , the number of orders that follow.
Each order is given as follows:
- The first line contains the road name for that order. No road name is longer than 50 characters.
- The second line states the total number of buildings that need new marble numbers in that order.
- Then come the house-number specifications, one per line. There are two kinds of lines:
- A single-number line consists of just one house number.
- A multiple-number line starts with a "+" sign, followed by three positive integers: the first number, the last number, and the interval between consecutive house numbers. The distance between the first and last number is always a multiple of the interval.
A house number never has more than five digits. After the last house-number specification line of an order, the next order follows, if there is one.
Output
For each order, the output consists of 13 lines.
- The first and second lines are identical to the first two input lines of that order (the road name and the building-count line).
- Then follow 10 lines describing how many marble digits of each kind are needed, one line per digit from 0 to 9, in the format
Make X digit Y, where is how many copies of digit must be made. - The last line states the total number of digits needed, in the format
In total Z digits. If exactly one digit must be produced, the line readsIn total 1 digitinstead, so that it stays grammatically correct.