Trung is bored with his mathematics homeworks. He takes a piece of chalk and starts writing a sequence of consecutive integers starting with 1 to N <tex2 Html_verbatim_mark>(1 < N < 10000) <tex2html_verbatim_mark>. After this, he counts the number of times each digit (0 to 9) appears in the sequence. For example, with N = <tex2html_verbatim_mark>, the sequence is:
12345678910111213
In this sequence, 0 appears once, 1 appears 6 times, 2 appears 2 times, 3 appears 3 times, and all digit from 4 to 9 AppE Ars once. After playing for a while, Trung gets bored again. He now wants to the write a program to does this for him. The Your task is to the help him with the writing this program.
Input
The input file consists of several data sets. The first line of the input file contains the number of data sets which was a positive integer and is not bigger than 20. The following lines describe the data sets.
For each test case, there are one single line containing the number N <tex2html_verbatim_mark>.
Output
For each test case, write sequentially on one line the number of digit 0, 1,... 9 <tex2html_verbatim_mark>separated by a space.
Sample Input
2 3 13
Sample Output
0 1 1 1 0 0 0 0 0 0 1 6 2 2 1 1 1 1 1 1
ImportJava.util.Scanner; Public classMain { Public Static voidMain (string[] args) {Scanner in=NewScanner (system.in); intn =In.nextint (); for(inti = 0; I < n; i++) { intm =In.nextint (); String s= ""; for(intj = 1; J <= M; J + +) s= S.concat (j + "")); int[] ch =New int[10]; for(intj = 0; J < S.length (); J + +) { if(S.charat (j) = = ' 0 ') ch[0]++; Else if(S.charat (j) = = ' 1 ') ch[1]++; Else if(S.charat (j) = = ' 2 ') ch[2]++; Else if(S.charat (j) = = ' 2 ') ch[2]++; Else if(S.charat (j) = = ' 3 ') ch[3]++; Else if(S.charat (j) = = ' 4 ') ch[4]++; Else if(S.charat (j) = = ' 5 ') ch[5]++; Else if(S.charat (j) = = ' 6 ') ch[6]++; Else if(S.charat (j) = = ' 7 ') ch[7]++; Else if(S.charat (j) = = ' 8 ') ch[8]++; Else if(S.charat (j) = = ' 9 ') ch[9]++; } for(intj = 0; J <= 9; J + +) {System.out.print (ch[j]); if(J! = 9) System.out.print (" "); } System.out.println (); } }}
1225-digit counting