## CCC '12 S2 - Aromatic Numbers

View as PDF

Points: 5
Time limit: 2.0s
Memory limit: 64M

Problem type
##### 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 Base value I V X L C D M 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

• commented on Sept. 1, 2021, 2:37 p.m.

Just a note, subtract AR NOT A'R'

However, wherever there are consecutive symbols ARA′R′ with R′ having a strictly bigger base value than R, the value of pair AR must be subtracted from the total, instead of being added.

• commented on July 25, 2021, 10:13 p.m. edit 2

...

• commented on July 29, 2021, 1:14 p.m.

I think it means that if the pair after the pair you are on is grater than it than you subtract????

• commented on July 30, 2021, 9:05 a.m.

That's what I thought but that doesn't explain why 3X2I4X is 68 when 3 10 is clearly larger than 2 1. Probably a typo tbh.

• commented on July 30, 2021, 1:24 p.m.

I finally did it! It is the pair AFTER the pair not in front, for example:3X2I4X tot = 0 so than it first adds 3*10, so total = 30 right now then since I is < than X so it subtracts 2I tot = 28 Then it adds 4X READ THE QUESTION, the coding is up to you now!:)

• commented on Jan. 22, 2021, 12:18 a.m.

I am confusion

• commented on Sept. 14, 2020, 11:33 a.m.

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.

• commented on Sept. 14, 2020, 4:54 p.m.

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.

• commented on May 16, 2020, 5:01 p.m.

Can dmoj not speak english?

• commented on Nov. 17, 2019, 9:37 a.m. edited

confusion noises

• commented on Oct. 29, 2019, 7:03 p.m.

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)

• commented on Jan. 5, 2015, 7:24 p.m.

This comment is hidden due to too much negative feedback. Show it anyway.