#C6005. Theoricum Value
Theoricum Value
Theoricum Value
You are given a string that represents a number in the Theoricum numeral system. The only valid symbols are X (which represents 10), V (which represents 5), and I (which represents 1). The numeral system uses a subtractive rule: when a symbol of a smaller value appears before a symbol of a larger value, its value is subtracted instead of added. For example, IV represents \(4\) because it is computed as \(5 - 1\), and XIV represents \(14\) (\(10 + (5-1)\)).
Your task is to compute the integer value represented by the given string of Theoricum symbols.
inputFormat
The input consists of a single line containing a non-empty string composed solely of the characters 'X', 'V', and 'I'. The input is read from stdin
.
outputFormat
Output a single integer representing the value of the Theoricum numeral string on a single line to stdout
.
XVI
16