MAIN Home Schedule Rules Compile PROBLEMS Novice Veteran All |
Return to the Top of Page, 2000 Index Page, Novice Problem Set, or Veteran Problem Set.
The original system of writing numbers used by the early Romans was simple but cumbersome. Various letters were used to represent important numbers, and these were then strung together to represent other numbers with the values decreasing monotonically from left to right. The letters they used and the numbers that were represented are given in the following table.
Thus 1993 was written as MDCCCCLXXXXIII. This system was then superseded by a partially place-oriented system, whereby if the above rule of decreasing values was broken, it meant that the immediately preceding (lower) value was deemed to be `negative' and was subtracted from the higher (out of place) value. In this system 1993 was usually written as MCMXCIII. There is still some controversy as to which letters could precede which other letters, but for the purposes of this problem we will assume the following restrictions:
Thus we could write MXMIII for 1993 or CCXCIV for 294, however we could not write ILV for 54. Note that 299 could be written as CCXCIX or CCIC. Write a program that will read in sums in Roman numerals and determine whether or not they are correct as Roman sums. Assume that zero will never appear on its own or as a leading digit.
InputInput will consist of a series of lines, each line consisting of an apparent Roman sum, i.e. a valid Roman number, a plus sign (+), another valid Roman number, an equal sign (=) and another valid Roman number. No Roman number will contain more than 9 letters. The file will be terminated by a line consisting of a single #.
OutputOutput will consist of a series of lines, one for each line of the input with either correct or incorrect on it. Output correct if the equality is true. Output incorrect if the equality is false.
Sample input
V+V=X X+X=XX XX+XX=MXC #
Sample output
Correct Correct Incorrect
Return to the Top of Page, 2000 Index Page, Novice Problem Set, or Veteran Problem Set. Test Data 0
V+V=X X+X=XX XX+XX=MXC #
Return to the Top of Page, 2000 Index Page, Novice Problem Set, or Veteran Problem Set. Output for Test Data 0
Correct Correct Incorrect
Return to the Top of Page, 2000 Index Page, Novice Problem Set, or Veteran Problem Set. Test Data 1
I+I=II MX+XL=ML M+D=MD VIII+I=IX VIII+I=XI #
Return to the Top of Page, 2000 Index Page, Novice Problem Set, or Veteran Problem Set. Output for Test Data 1
Correct Correct Correct Correct Incorrect
Return to the Top of Page, 2000 Index Page, Novice Problem Set, or Veteran Problem Set. Test Data 2
MMM+I=CMI MMM+I=MMML XXX+XXVI=MVI CD+MDLXVI=MMLXVI #
Return to the Top of Page, 2000 Index Page, Novice Problem Set, or Veteran Problem Set. Output for Test Data 2
Incorrect Incorrect Incorrect Incorrect
Return to the Top of Page, 2000 Index Page, Novice Problem Set, or Veteran Problem Set.
|
This page last updated Fri Feb 11 21:55:29 2000.