#K56427. Roman Numerals to Integer
Roman Numerals to Integer
Roman Numerals to Integer
You are given a string representing a Roman numeral. Your task is to convert this Roman numeral into its integer value.
The Roman numeral is given in its standard form where the mapping is defined as:
\( I=1,\; V=5,\; X=10,\; L=50,\; C=100,\; D=500,\; M=1000 \)
Note that the numeral uses subtractive notation; for example, \( IV \) represents 4 and \( IX \) represents 9.
Input: A single Roman numeral string.
Output: An integer value corresponding to the Roman numeral.
inputFormat
The input consists of a single line containing a Roman numeral string composed of the characters {I, V, X, L, C, D, M}. The string is non-empty and represents a valid Roman numeral.
outputFormat
Output a single integer which is the value of the given Roman numeral.
## sampleI
1