#C4495. Roman Numeral to Integer Conversion

    ID: 48039 Type: Default 1000ms 256MiB

Roman Numeral to Integer Conversion

Roman Numeral to Integer Conversion

You are given a string representing a Roman numeral, and your task is to convert it into an integer. Roman numerals are represented by the symbols (I, V, X, L, C, D, M) which correspond to the values (1, 5, 10, 50, 100, 500, 1000) respectively. When a smaller numeral appears before a larger numeral, it is subtracted from the larger numeral. For example, (IV = 4) and (IX = 9). Write a program that reads a Roman numeral from standard input and outputs its integer equivalent.

inputFormat

A single line containing a valid Roman numeral string. For example: III or MCMXCIV.

outputFormat

An integer representing the value of the given Roman numeral. For example, the output for III is 3.## sample

III
3

</p>