青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

Yiner的ACM

成長(zhǎng)的痕跡
<2011年2月>
303112345
6789101112
13141516171819
20212223242526
272812345
6789101112

統(tǒng)計(jì)

  • 隨筆 - 29
  • 文章 - 0
  • 評(píng)論 - 2
  • 引用 - 0

常用鏈接

留言簿(1)

隨筆分類(lèi)

隨筆檔案

搜索

  •  

最新評(píng)論

閱讀排行榜

評(píng)論排行榜

字符串處理 A-Metsys Laremun

 

Prof. Hachioji has devised a new numeral system of integral numbers with four lowercase letters "m", "c", "x", "i" and with eight digits "2", "3", "4", "5", "6", "7", "8", "9". He doesn't use digit "0" nor digit "1" in this system.

The letters "m", "c", "x" and "i" correspond to 1000, 100, 10 and 1, respectively, and the digits "2", ...,"9" correspond to 2, ..., 9, respectively. This system has nothing to do with the Roman numeral system.

For example, character strings

"5m2c3x4i", "m2c4i" and "5m2c3x"

correspond to the integral numbers 5234 (=5*1000+2*100+3*10+4*1), 1204 (=1000+2*100+4*1), and 5230 (=5*1000+2*100+3*10), respectively. The parts of strings in the above example, "5m", "2c", "3x" and "4i" represent 5000 (=5*1000), 200 (=2*100), 30 (=3*10) and 4 (=4*1), respectively.

 

Each of the letters "m", "c", "x" and "i" may be prefixed by one of the digits "2", "3", ..., "9". In that case, the prefix digit and the letter are regarded as a pair. A pair that consists of a prefix digit and a letter corresponds to an integer that is equal to the original value of the letter multiplied by the value of the prefix digit.

For each letter "m", "c", "x" and "i", the number of its occurrence in a string is at most one. When it has a prefix digit, it should appear together with the prefix digit. The letters "m", "c", "x" and "i" must appear in this order, from left to right. Moreover, when a digit exists in a string, it should appear as the prefix digit of the following letter. Each letter may be omitted in a string, but the whole string must not be empty. A string made in this manner is called an MCXI-string.

An MCXI-string corresponds to a positive integer that is the sum of the values of the letters and those of the pairs contained in it as mentioned above. The positive integer corresponding to an MCXI-string is called its MCXI-value. Moreover, given an integer from 1 to 9999, there is a unique MCXI-string whose MCXI-value is equal to the given integer. For example, the MCXI-value of an MCXI-string "m2c4i" is 1204 that is equal to 1000 + 2*100 + 4*1. There are no MCXI-strings but "m2c4i" that correspond to 1204. Note that strings "1m2c4i", "mcc4i", "m2c0x4i", and "2cm4i" are not valid MCXI-strings. The reasons are use of "1", multiple occurrences of "c", use of "0", and the wrong order of "c" and "m", respectively.

Your job is to write a program for Prof. Hachioji that reads two MCXI-strings, computes the sum of their MCXI-values, and prints the MCXI-string corresponding to the result.

Input

The input is as follows. The first line contains a positive integer n (<= 500) that indicates the number of the following lines. The k+1 th line is the specification of the k th computation (k=1, ..., n).

n
specification1
specification2
...
specificationn

Each specification is described in a line:

MCXI-string1 MCXI-string2

The two MCXI-strings are separated by a space.

 

You may assume that the sum of the two MCXI-values of the two MCXI-strings in each specification is less than or equal to 9999.

Output

For each specification, your program should print an MCXI-string in a line. Its MCXI-value should be the sum of the two MCXI-values of the MCXI-strings in the specification. No other characters should appear in the output.

Sample Input

10
xi x9i
i 9i
c2x2i 4c8x8i
m2ci 4m7c9x8i
9c9x9i i
i 9m9c9x8i
m i
i m
m9i i
9m8c7xi c2x8i

Sample Output

3x
x
6cx
5m9c9x9i
m
9m9c9x9i
mi
mi
mx
9m9c9x9i

posted on 2011-03-20 19:37 Yiner 閱讀(217) 評(píng)論(0)  編輯 收藏 引用


只有注冊(cè)用戶(hù)登錄后才能發(fā)表評(píng)論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            欧美国产日本高清在线| 亚洲人成在线观看网站高清| 久久夜色精品国产欧美乱| 性色一区二区| 久久国内精品自在自线400部| 午夜视黄欧洲亚洲| 欧美一区免费| 美国十次成人| 欧美理论电影在线播放| 欧美视频免费| 国产情人综合久久777777| 国产主播精品在线| 亚洲国产黄色| 亚洲视频国产视频| 午夜视频一区二区| 久久亚洲影院| 亚洲经典在线看| 亚洲精品欧洲精品| 午夜视频在线观看一区| 久久亚洲高清| 国产精品mm| 加勒比av一区二区| 99热在线精品观看| 欧美一区二区三区在线观看| 久久综合色88| 一区二区三区 在线观看视| 欧美一区二区精品| 欧美久久久久久久| 国产亚洲一级高清| 亚洲特级毛片| 欧美大片网址| 午夜国产一区| 欧美色区777第一页| 亚洲国产经典视频| 欧美尤物巨大精品爽| 欧美国产日韩精品免费观看| 亚洲一区二区欧美| 欧美国产精品专区| 亚洲成人原创| 久久精品国产亚洲a| 亚洲视频视频在线| 欧美精品在线播放| 亚洲国产99精品国自产| 久久精品一二三区| 亚洲一区黄色| 国产精品美女一区二区| 一区二区三区产品免费精品久久75| 久久在线视频在线| 99国产精品国产精品毛片| 久久这里有精品15一区二区三区| 亚洲欧美国产精品va在线观看| 欧美国产一区二区在线观看 | 欧美—级高清免费播放| 国产亚洲激情视频在线| 香蕉久久夜色精品| 正在播放欧美一区| 欧美系列一区| 一区二区高清在线观看| 亚洲激情成人网| 乱码第一页成人| 在线观看91精品国产入口| 久久久91精品国产一区二区精品| 亚洲性感美女99在线| 国产精品v日韩精品v欧美精品网站| 亚洲精选视频免费看| 亚洲高清av| 欧美国产精品v| 亚洲精品偷拍| 日韩亚洲欧美精品| 国产精品视频九色porn| 亚洲欧美日韩在线一区| 亚洲一区二区在线| 国产一区二区三区高清播放| 久久久xxx| 久久精品国产亚洲aⅴ| 黄色在线一区| 久热精品在线| 欧美福利一区二区| 在线综合亚洲欧美在线视频| 一区二区三区不卡视频在线观看 | 国模叶桐国产精品一区| 久久先锋资源| 男男成人高潮片免费网站| 夜夜嗨av一区二区三区| 一区二区三区波多野结衣在线观看| 国产精品视频在线观看| 久久久久久久久岛国免费| 免费成人高清视频| 亚洲午夜一区| 欧美一级在线亚洲天堂| 亚洲国产欧美日韩精品| 日韩视频一区二区三区在线播放免费观看| 欧美日韩精品三区| 久久国产精品一区二区三区| 久久夜色精品国产欧美乱极品| 99ri日韩精品视频| 午夜精品一区二区三区电影天堂| 亚洲成色精品| 亚洲午夜羞羞片| 亚洲第一黄网| 亚洲一区二区在线| 亚洲精品久久久久久久久久久| 亚洲午夜免费福利视频| 久久综合电影| 亚洲免费视频中文字幕| 久久久久久一区二区| 中文国产成人精品| 久久躁日日躁aaaaxxxx| 亚洲免费小视频| 欧美成人精品在线播放| 久久精彩视频| 欧美视频成人| 亚洲国产精品va在看黑人| 国产视频一区在线| 亚洲乱码国产乱码精品精可以看 | 99精品视频免费全部在线| 国产亚洲成精品久久| 亚洲美女淫视频| 在线观看欧美激情| 亚洲欧美制服另类日韩| 一区二区三区三区在线| 麻豆91精品91久久久的内涵| 欧美在线观看网站| 欧美调教视频| 亚洲免费观看| 亚洲精品欧洲精品| 美女黄色成人网| 久久这里只精品最新地址| 国产精品一卡二卡| 一区二区三区精品久久久| 日韩一级在线观看| 欧美91大片| 欧美福利小视频| 怡红院av一区二区三区| 久久高清一区| 久久综合999| 伊人影院久久| 老司机午夜免费精品视频| 玖玖视频精品| …久久精品99久久香蕉国产 | 亚洲第一综合天堂另类专| 久久久精品一区二区三区| 久久精品国产免费看久久精品| 国产精品永久免费视频| 在线综合亚洲欧美在线视频| 亚洲一级在线观看| 国产精品尤物福利片在线观看| 亚洲一区二区三区在线看| 亚洲色图自拍| 国产精品午夜在线| 欧美亚洲在线| 免费观看欧美在线视频的网站| 在线观看精品视频| 嫩模写真一区二区三区三州| 亚洲激情二区| 亚洲一级一区| 国产三级欧美三级日产三级99| 午夜精品视频| 久久久久久久久久久成人| 永久免费精品影视网站| 欧美jjzz| 亚洲一品av免费观看| 久久婷婷成人综合色| 亚洲国产欧美国产综合一区| 欧美日韩在线播放一区| 亚洲一区二区三区免费观看| 亚洲日本在线观看| 老**午夜毛片一区二区三区| 韩国女主播一区二区三区| 玖玖玖国产精品| 亚洲激情欧美| 亚洲欧美日韩精品久久亚洲区 | 国产精品久久久久久超碰| 欧美一区二视频| 亚洲国产精品成人精品| 亚洲欧美影院| 亚洲国产成人久久综合| 国产精品高清网站| 久久午夜电影| 亚洲午夜激情网站| 亚洲国产日韩欧美在线图片| 亚洲综合精品四区| 亚洲人永久免费| 国产欧美午夜| 欧美成人午夜77777| 亚洲宅男天堂在线观看无病毒| 欧美二区在线播放| 久久se精品一区精品二区| 亚洲裸体在线观看| 国产主播喷水一区二区| 国产精品国产精品国产专区不蜜| 久久综合久久综合九色| 亚洲女优在线| 亚洲伦理在线| 亚洲电影免费观看高清| 久久久99国产精品免费| 午夜精品福利在线观看| 一本色道久久综合狠狠躁篇的优点| 韩国女主播一区| 国产欧亚日韩视频|