DMOPC '15 Contest 4 P5 - Scribe

View as PDF

Submit solution


Points: 15 (partial)
Time limit: 0.6s
Memory limit: 64M

Author:
Problem type

Library and Archives Canada has decided to archive all English essays from Canadian high schools so that they may be preserved for future generations to study, and Brian Kernighan (of K&R C fame) has been hired to manually type up the page numbers in the margin of every page. Since his keyboard's numpad has a limited number of key presses before the buttons break, he'd like to know if he'll be able to type up all essays without breaking his keyboard (or determine that he'll have to order a new computer with a sturdier keyboard).

Kernighan has been given T essays, where essay i should be numbered from x_i to y_i inclusive. For each essay, he'd like to know how many times each integer 0-9 appears in the page number range. So that you don't lose this once-in-a-lifetime chance of talking with a legend, you've decided to write a program to answer his queries and impress him!

Constraints

Subtask 1 [10%]

1 \le T \le 50
1 \le x \le y \le 2\,000

Subtask 2 [90%]

1 \le T \le 10\,000
1 \le x \le y \le 10^9

Input Specification

The first line of the input will contain the integer T.
For the next T lines of input, line i will contain two space-separated integers x_i and y_i.

Output Specification

For each essay, output 10 integers on a line, separated by a single space. Integer i will contain the number of times the digit i appears in the essay's page range.

Sample Input

10
1 10
346 542
1199 1748
1403 1496
503 1004
190 1714
854 1317
494 1976
1001 1960
44 497

Sample Output

1 2 1 1 1 1 1 1 1 1
40 40 40 93 136 82 40 40 40 40
115 666 215 215 214 205 205 154 105 106
16 113 19 20 114 20 20 19 19 16
107 105 100 101 101 197 200 200 200 200
413 1133 503 503 503 502 502 417 402 412
196 512 186 104 87 93 97 97 142 196
398 1375 398 398 405 499 499 495 488 471
294 1256 296 296 296 296 287 286 286 247
85 185 185 185 190 96 96 96 95 93

Comments

There are no comments at the moment.