UVa 344

From Algorithmist
Jump to: navigation, search

344 - Roman Digititis[edit]

Summary[edit]

Figure out the number of i,v,x,l,c in a book with n pages

Explanation[edit]

  • For each number from 1 to n figure out how many i,v,x,l,c are in a book of size n.
  • Just keep track of it in an array or something and output it in the end.

Input[edit]

1
2
20
99
0

Output[edit]

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

Solution[edit]