#C10577. Roman Numeral to Integer

    ID: 39797 Type: Default 1000ms 256MiB

Roman Numeral to Integer

Roman Numeral to Integer

In this problem, you are given a Roman numeral as a string. Your task is to convert it to its corresponding integer value. Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. The integer value is computed by summing the values of the symbols, except for cases where a smaller numeral appears before a larger numeral indicating subtraction. For example, "IV" represents 4 and "MCMXCIV" represents 1994.

Note: Although some sequences like "IIII" are not standard, they should be processed by simply adding the individual numeral values.

inputFormat

Input is read from standard input (stdin) and consists of a single line containing a non-empty Roman numeral string.

outputFormat

Output the integer value corresponding to the given Roman numeral on a single line to standard output (stdout).## sample

III
3