CCC '96 S4 - When in Rome
View as PDFIf the Roman Empire had not fallen, then Rome would surely have discovered electricity and used electronic calculators; however, the Romans used Roman Numerals! Your task is to implement a simple Roman Calculator which accepts two Roman Numerals and outputs the sum in Roman Numerals. You may assume that numbers greater than 1000 will not occur in the input. Output numbers greater than 1000 are illegal and should generate the message CONCORDIA CUM VERITATE (In Harmony with Truth).
The input consists of a number, indicating the number of test cases, followed
by this many test cases. Each test case consists of a single line with two
numbers in Roman Numerals separated by a + along with an = at the end.
There are no separating spaces.
For each test case, the output is a copy of the input with the Roman Numeral that represents the sum on a separate line.
Roman Research
The Roman Numerals used by the Romans evolved over many years, and so there are some variations in the way they are written. We will use the following definitions:
- The following symbols are used: 
Ifor 1,Vfor 5,Xfor 10,Lfor 50,Cfor 100,Dfor 500, andMfor 1000. - Numbers are formed by writing symbols from 1. from left to right, as a sum, each time using the symbol for the largest possible value. The symbols 
M,C,X, orImay be used at most three times in succession. Only if this rule would be violated, you can use the following rule:- When a single 
Iimmediately precedes aVorX, it is subtracted. When a singleXimmediately precedes anLorC, it is subtracted. When a singleCimmediately precedes aDorM, it is subtracted. 
 - When a single 
 
For example: II = 2; IX = 9; CXIII = 113; LIV = 54; XXXVIII = 38; XCIX = 99.
Sample Input
3
VII+II=
XXIX+X=
M+I=
Sample Output
VII+II=IX
XXIX+X=XXXIX
M+I=CONCORDIA CUM VERITATE
Comments
this question is weirdly fun
For example, if it was IIX, would that be 10, or 12? I find the problem statement about this section a bit confusing.
IIXis not a valid Roman Numeral.I'm still kind of confused why it isn't a roman numeral? Update: never mind i found out why
wait, why???
(Emphasis mine.)
You cannot have two
Is preceding anX.DMOJ output is different from my local machine.
Have I hardcoded too much for my submission to be illegitimate?