This question involves calculating the value of aromatic numbers which are a combination of Arabic digits and Roman numerals.
本题是关于计算芳香数数值的问题,芳香数是阿拉伯数字和罗马数字的组合。
An aromatic number is of the form ARARAR...AR, where each A is an Arabic digit, and each R is a Roman numeral. Each pair AR contributes a value described below, and by adding or subtracting these values together we get the value of the entire aromatic number.
芳香数的格式是ARARAR..ARA,其中A代表阿拉伯数字,R代表罗马数字。每一对AR按照下面的计算方式计算一个值,通过把这些数值加减起来,就得到了整个芳香数的数值。
An Arabic digit A can be 0, 1, 2, 3, 4, 5, 6, 7, 8 or 9. A Roman numeral R is one of the seven letters I, V, X, L, C, D, or M. Each Roman numeral has a base value:
阿拉伯数字是0,1,2..9,罗马数字是I,V,X,L,C,D,M。
Symbol I V X L C D M Base value 1 5 10 50 100 500 1000
符号I V X L C D M的值是1 5 10 50 100 500 1000。
The value of a pair AR is A times the base value of R. Normally, you add up the values of the pairs to get the overall value. However, wherever there are consecutive symbols ARA0R0 with R0 having a strictly bigger base value than R, the value of pair AR must be subtracted from the total, instead of being added.
一对AR的值计算为A乘以R。一般的,我们把所有的AR的值加起来就得到了芳香数的值。但是如果存在连续的两个数对ARA0R0,其中R0严格大于R的话,则需要减去AR的值,而不是加上。
For example, the number 3M1D2C has the value 3∗1000+1∗500+2∗100 = 3700 and 3X2I4X has the value 3 ∗ 10 − 2 ∗ 1 + 4 ∗ 10 = 68.
举个例子,3M1D2C 的值为3*1000+1*500+2*100=3700,而3X2I4X的值为3*10-2*1+4*10=68
Write a program that computes the values of aromatic numbers.
你的任务是写一个程序来计算一个给定的芳香数的值。