当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3353:Nuevo-Romano

题目描述

``The system of Roman numerals is a numeral system originating from ancient Rome, and was adapted from Etruscan numerals. The system used in classical antiquity was slightly modified in the Middle Ages to produce the system we use today. It is based on certain letters which are given values as numerals." (From wikipedia.org)

Since ACM is where innovation starts, a new numeral system, called Nuevo-Romano, is derived from the Roman numerals with one slight modification. The basic set of Roman Numeral systems are:

  • I or i for one
  • V or v for five
  • X or x for ten
  • L or l for fifty
  • C or c for one hundred
  • D or d for five hundred
  • M or m for one thousand

Nuevo-Romano extends it by adding `O' or `o' to mean multiplied by one thousand. However, the new numeral is only applied to numerals greater than 3 or III or iii, e.g.

  • IVO or ivo for four thousand
  • VO or vo for five thousand
  • XO or xo for ten thousand
  • MO or mo for one million

The same rules for multiple symbol combinations to produce numbers between these values are applied.

  1. The number is written using the symbols with the symbol of highest value as the first numeral followed by a symbol of lower value except in special cases as defined below. Example: MMMDCCCLXXVIII = 3,878.
  2. The I or i, X or x, C or c and M or m can be repeated up to a maximum of three times, e.g. III or iii for three, XXX or xxx for thirty, CC or cc for two hundred and MM or mm for two thousand.
  3. V, L and D can only be used once.
  4. I, X and C can appear before a larger symbol to indicate subtraction. Only the following are allowed:

    IV = 5 - 1 = 4

    IX = 10 - 1 = 9

    XL = 50 - 10 = 40

    XC = 100 - 10 = 90

    CD = 500 - 100 = 400

The task is to determine the sum of two Nuevo-Romano numbers and output both the Nuevo-Romano number and the Latin alphabet-based Arabic number.

输入解释

Each line in the input consists of two Nuevo-Romano numbers separated by a `+' sign. The input is in mixed case. If the given Nuevo-Romano number is not a valid one, print ``INVALID" in the line.

No strings presumed to be a Nuevo-Romano number will exceed 100 in length.

输出解释

The sum expressed as a Nuevo-Romano number in uppercase and its Arabic number form separated by an `=' sign.

输入样例
XLII+CC 
MODccXLIX+cxi 
COD+IC 
LXIIOCCLXXXVIII+IVOCXX
输出样例
CCXLII=242 
MODCCCLX=1000860 
INVALID 
LXVIOCDVIII=66408
提示
1. multiple 'O' is allowed
2. 'O' followed by 'M' is invalid

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 Manila 2006

源链接: POJ-3353

最后修改于 2020-10-29T06:59:27+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536