Roman Digititis
Difficulty: Hard

Many persons are familiar with the Roman numerals for relatively small numbers. The symbols "i", "v", "x", "l", and "c" represent the decimal values 1, 5, 10, 50, and 100 respectively. To represent other values, these symbols, and multiples where necessary, are concatenated, with the smaller-valued symbols written further to the right. For example, the number 3 is represented as "iii", and the value 73 is represented as "lxxiii". The exceptions to this rule occur for numbers having units values of 4 or 9, and for tens values of 40 or 90. For these cases, the Roman numeral representations are "iv" (4), "ix" (9), "xl" (40), and "xc" (90). So the Roman numeral representations for 24, 39, 44, 49, and 94 are "xxiv", "xxxix", "xliv", "xlix", and "xciv", respectively.

The preface of many books has pages numbered with Roman numerals, starting with "i" for the first page of the preface, and continuing in sequence. Assume books with pages having 100 or fewer pages of preface. How many "i", "v", "x", "l", and "c" characters are required to number the pages in the preface? For example, in a five page preface we’ll use the Roman numerals "i", "ii", "iii", "iv", and "v", meaning we need 7 "i" characters and 2 "v" characters.

**Input Format:**
The input will consist of a sequence of integers in the range 1 to 100, terminated by a zero. For each such integer, except the final zero, determine the number of different types of characters needed to number the prefix pages with Roman numerals.

**Output Format:**
For each integer in the input, write one line containing the input integer and the number of characters of each type required. The examples shown below illustrate an acceptable format.

**Example Input:**
 
1  
2  
20  
99  
0  

**Expected Output:**  
  
1: 1 i, 0 v, 0 x, 0 l, 0 c  
2: 3 i, 0 v, 0 x, 0 l, 0 c  
20: 28 i, 10 v, 14 x, 0 l, 0 c  
99: 140 i, 50 v, 150 x, 50 l, 10 c  

Input Format:

Output Format:

Sample Input:

Sample Output:

Python 3 starter code:


Reference solution (C++):
	#include <stdio.h>
	#include<stdlib.h>

	int ni, nv, nx, nl, nc;

	void units(int n)
	{
    switch(n) {
	case 0: break;
	case 1: ni += 1; break;
	case 2: ni += 2; break;
	case 3: ni += 3; break;
	case 4: ni += 1; nv += 1; break;
	case 5: nv += 1; break;
	case 6: ni += 1; nv += 1; break;
	case 7: ni += 2; nv += 1; break;
	case 8: ni += 3; nv += 1; break;
	case 9: ni += 1; nx += 1; break;
	default: printf("bomb!\n"); exit(0);
    }
	}

	void tens(int n)
	{
    switch(n) {
	case 0: break;
	case 1: nx += 1; break;
	case 2: nx += 2; break;
	case 3: nx += 3; break;
	case 4: nx += 1; nl += 1; break;
	case 5: nl += 1; break;
	case 6: nx += 1; nl += 1; break;
	case 7: nx += 2; nl += 1; break;
	case 8: nx += 3; nl += 1; break;
	case 9: nx += 1; nc += 1; break;
	case 10: nc += 1; break;
	default: printf("tens bomb!\n"); exit(0);
    }
	}

	main()
	{
    int i, n;

    while(1) {
	scanf("%d",&n);
	if (n == 0) exit(0);
	ni = nv = nx = nl = nc = 0;
	for (i=1;i<=n;i++) {
	    units(i % 10);
	    tens(i / 10);
	}
	printf("%d: %d i, %d v, %d x %d l, %d c\n", n, ni, nv, nx, nl, nc);
    }
	}