Canadian Computing Competition: 2012 Stage 1, Senior #2
This question involves calculating the value of aromatic numbers which are a combination of Arabic digits and Roman numerals.
An aromatic number is of the form , where each is an Arabic digit, and each is a Roman numeral. Each pair contributes a value described below, and by adding or subtracting these values together we get the value of the entire aromatic number.
An Arabic digit can be 0, 1, 2, 3, 4, 5, 6, 7, 8 or 9. A Roman numeral is one of the seven letters I, V, X, L, C, D, or M. Each Roman numeral has a base value:
Symbol | I | V | X | L | C | D | M |
---|---|---|---|---|---|---|---|
Base value | 1 | 5 | 10 | 50 | 100 | 500 | 1000 |
The value of a pair is times the base value of . Normally, you add up the values of the pairs to get the overall value. However, wherever there are consecutive symbols with having a strictly bigger base value than , the value of pair must be subtracted from the total, instead of being added.
For example, the number has the value and has the value .
Write a program that computes the values of aromatic numbers.
Input Specification
The input is a valid aromatic number consisting of between and symbols.
Output Specification
The output is the decimal value of the given aromatic number.
Sample Input 1
3M1D2C
Output for Sample Input 1
3700
Sample Input 2
2I3I2X9V1X
Output for Sample Input 2
-16
Comments
For sample input 2:
2I3I2X9V1X
=2×1 + 3×1 + 2×10 + 9×5 + 1×10
This means that
3×1 + 2×10
becomes-3×1 + 2×10
and9×5 + 1×10
becomes-9×5 + 1×10
. So the equation is rewritten as:2I3I2X9V1X
=2×1 - 3×1 + 2×10 - 9×5 + 1×10
=-16
Hope this helps :)
Confusing cuz' no explanation
Just a note, subtract AR NOT A'R'
I am confusion
This problem is extremely unclear and needs revised instructions, as well as an explanation for at least one sample. It should be harder to complete the coding challenge than to actually read the instructions for it.
DMOJ does not generally modify problem statements that we get from other sources (this is a CCC problem).
If you have any feedback about CCC feel free to get in touch with the CEMC.
Can dmoj not speak english?
confusion noises
Note: From the example 3X2I4X, because 2I(AR)'s base is smaller than 4X(A′R′), so 2I(AR) should be subtracted from the total(-2 * I = -2 * 1)
This comment is hidden due to too much negative feedback. Show it anyway.