#K77482. Roman Numeral Sum Calculator

    ID: 34874 Type: Default 1000ms 256MiB

Roman Numeral Sum Calculator

Roman Numeral Sum Calculator

This problem requires you to calculate the sum of a series of Roman numeral expressions. The input is a single string consisting of valid Roman numerals separated by the plus sign (+). Each Roman numeral follows standard rules including subtractive notation. Your task is to convert each Roman numeral into its corresponding integer value and then sum them up.

For example, given the string X+V+XII, you should compute the result as follows:

\( 10 + 5 + 12 = 27 \)

Note: The valid Roman numeral symbols are I, V, X, L, C, D, M. The conversion follows the standard algorithm: when a numeral of lower value precedes one of higher value, it is subtracted rather than added. For instance, \(IV\) is interpreted as \(5-1=4\).

inputFormat

The input consists of a single line containing a string s, which is a Roman numeral expression. The numerals are separated by the plus sign (+).

stdin Example:

X+V+XII

outputFormat

Output a single integer, which is the sum of the integer values of the Roman numerals in the expression.

stdout Example:

27
## sample
X
10

</p>