Czech ACM Student Chapter
Czech Technical University in Prague
Charles University in Prague
Technical University of Ostrava
Slovak University of Technology
CTU Open Contest 2007
expr.c, expr.C, expr.p, expr.java
As any other marketing company, ACM produces a lot of funky advertising items that may
contain a logo and be given to customers and business partners as small gifts. A unique specialty
of ACM is a calculator that uses roman numbers.
Roman numbers are able to express any non-negative integer using uppercase letters:
Numbers are created by appending several letters together, the letter representing a higher value
must always precede letters with lower values. The only exception are the letters "I", "X", and
"C", they may be used before higher letters to form values expressed by digits 4 and 9. The only
possible combinations are:
Pair of Letters
Any roman number must first express thousands, then hundreds, tens, and ones. Therefore, 499
must always be written as "CDXCIX", not "ID".
Although not very practical, this gift is considered extremely "cooooool". Your task is to write
software for that calculator.