#C8390. Roman Numerals to Integer Conversion
Roman Numerals to Integer Conversion
Roman Numerals to Integer Conversion
In this problem, you are given a Roman numeral string and your task is to convert it to its integer value. Roman numerals are represented by seven different symbols: I, V, X, L, C, D, and M. Numerals are usually written largest to smallest from left to right. However, in some cases, a smaller numeral appears before a larger numeral, indicating that it should be subtracted. For example, IV represents 4, and IX represents 9.
The conversion rules are based on the standard Roman numeral system. The conversion follows the formula: $$\text{value} = \sum_{i=1}^{n} (roman\_value)$$, applying subtraction when a smaller numeral precedes a larger one.
inputFormat
The input consists of a single line containing a non-empty Roman numeral string. The string is guaranteed to represent an integer in the range from 1 to 3999. Valid characters include: 'I', 'V', 'X', 'L', 'C', 'D', 'M'.
outputFormat
Output a single integer representing the numerical value of the Roman numeral provided in the input.
## sampleIII
3