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

Yiner的ACM

成長的痕跡
<2011年4月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

統計

  • 隨筆 - 29
  • 文章 - 0
  • 評論 - 2
  • 引用 - 0

常用鏈接

留言簿(1)

隨筆分類

隨筆檔案

搜索

  •  

最新評論

閱讀排行榜

評論排行榜

字符串處理 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) 評論(0)  編輯 收藏 引用

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            久久久久久69| 欧美亚洲成人精品| 99精品欧美一区二区三区综合在线| 欧美成人一区二区三区片免费| 麻豆精品传媒视频| 欧美国产视频日韩| 日韩一级成人av| 亚洲欧美精品一区| 久久久久久久精| 欧美黄色精品| 国产精品丝袜xxxxxxx| 国产亚洲毛片| 99精品国产高清一区二区 | 噜噜噜噜噜久久久久久91| 久久综合网色—综合色88| 欧美黄在线观看| 午夜在线播放视频欧美| 久久久精品动漫| 亚洲另类一区二区| 久久精品一区| 欧美午夜精品理论片a级按摩| 国产日本欧美在线观看| 亚洲精品一区二区三区婷婷月| 午夜精品福利视频| 欧美国产一区二区在线观看| 一区二区三区导航| 狂野欧美一区| 国内精品免费午夜毛片| 亚洲午夜一区二区三区| 欧美va天堂在线| 欧美一级大片在线观看| 美女黄毛**国产精品啪啪 | 亚洲一区视频| 你懂的视频欧美| 国产在线麻豆精品观看| 亚洲欧美日韩久久精品| 亚洲精品一区二区三区不| 久久人人精品| 国内精品嫩模av私拍在线观看| 亚洲男人第一网站| 亚洲美女福利视频网站| 嫩模写真一区二区三区三州| 伊人色综合久久天天| 久久久亚洲国产天美传媒修理工 | 亚洲欧美偷拍卡通变态| 欧美精品一区二区精品网 | 亚洲精品视频在线观看免费| 久久亚洲欧洲| 欧美一区二区性| 国产欧美亚洲一区| 亚洲免费影视| 99精品视频免费观看视频| 欧美激情视频一区二区三区免费 | 亚洲欧洲在线免费| 久久国产精品免费一区| 国产欧美亚洲日本| 午夜精品国产更新| 一区二区三区四区国产精品| 欧美母乳在线| 日韩视频―中文字幕| 免费在线亚洲| 久久久另类综合| 在线观看精品视频| 欧美国产先锋| 欧美/亚洲一区| 日韩视频免费观看高清完整版| 亚洲高清自拍| 欧美偷拍一区二区| 亚洲一区二区在线免费观看视频| 在线一区二区三区四区五区| 国产精品视频一区二区高潮| 久久亚洲精品中文字幕冲田杏梨| 蜜桃av噜噜一区| 亚洲一区二区三区中文字幕在线| 一本色道久久综合亚洲二区三区| 欧美午夜激情小视频| 久久国产视频网| 欧美va天堂| 亚洲在线免费| 久久国产精品久久w女人spa| 亚洲国产日韩欧美综合久久| 亚洲精品中文字幕在线| 国产精品视频久久久| 久久久久久久综合| 久久精品免费播放| 免费看成人av| 欧美午夜不卡影院在线观看完整版免费| 亚洲欧洲一区| 在线亚洲免费| 国产一区二区三区最好精华液| 久久精品91久久香蕉加勒比| 蜜桃视频一区| 亚洲综合久久久久| 久久精品人人做人人综合| 亚洲精品美女| 先锋影音国产一区| 亚洲国产老妈| 亚洲男女自偷自拍图片另类| 亚洲人成网站色ww在线| 亚洲伊人网站| 91久久国产综合久久蜜月精品 | 另类天堂av| 亚洲一区二区免费在线| 久久久久国产一区二区三区| 亚洲在线不卡| 欧美日本高清| 六月天综合网| 国产精品一区二区久久国产| 最新亚洲一区| 影音先锋中文字幕一区| 亚洲校园激情| 亚洲视频一二| 欧美日韩mp4| 欧美激情久久久久久| 国产一区在线免费观看| 亚洲一区二区三区在线| 99亚洲一区二区| 女人天堂亚洲aⅴ在线观看| 老牛国产精品一区的观看方式| 国产精品毛片a∨一区二区三区| 亚洲第一在线综合在线| 在线精品视频一区二区三四| 久久精品国产免费观看| 久久福利视频导航| 国产精品女主播| 亚洲一区在线观看视频| 亚洲欧美另类久久久精品2019| 欧美欧美天天天天操| 亚洲黄色视屏| 一区二区三区回区在观看免费视频| 欧美精品免费播放| 亚洲靠逼com| 亚洲午夜久久久久久久久电影院| 欧美日韩免费一区二区三区| 亚洲乱码国产乱码精品精天堂| 亚洲毛片视频| 欧美日韩精品一区二区天天拍小说 | 国产一区二区高清不卡| 新狼窝色av性久久久久久| 欧美在线视频导航| 国产一区二区三区四区在线观看| 久久免费高清视频| 午夜精品剧场| 国产精品久久久久久久久久直播| 一区二区三区四区蜜桃| 亚洲影院污污.| 国产一区二区中文字幕免费看| 欧美在线观看日本一区| 欧美插天视频在线播放| 99精品国产在热久久婷婷| 国产精品福利av| 久久er99精品| 亚洲精品日韩综合观看成人91| 亚洲图片你懂的| 国产亚洲精品美女| 久久日韩粉嫩一区二区三区| 亚洲第一视频网站| 亚洲尤物精选| 狠狠色狠色综合曰曰| 欧美电影免费| 亚洲欧美国产另类| 久久亚洲国产成人| 99精品免费视频| 国产欧美日韩在线视频| 免费在线成人av| 亚洲一区影院| 欧美激情精品| 欧美一区二区三区久久精品茉莉花| 亚洲高清免费| 国产精品综合| 欧美日本国产精品| 久久久久久亚洲精品杨幂换脸 | 999亚洲国产精| 久久三级视频| 亚洲婷婷在线| 亚洲另类视频| 永久免费视频成人| 欧美日韩精品在线视频| 久久久精品一区| 在线视频欧美日韩| 亚洲电影免费在线观看| 久久久久久97三级| 一区二区三区.www| 亚洲福利视频一区二区| 国产欧美日韩在线| 国产精品久久久99| 欧美精品aa| 欧美成人精品1314www| 久久福利资源站| 亚洲欧美激情精品一区二区| 日韩亚洲视频| 最新中文字幕一区二区三区| 免费不卡欧美自拍视频| 久久色在线播放| 欧美尤物一区| 亚洲综合丁香| 亚洲一级影院| 一本久久a久久免费精品不卡| 91久久久久久| 亚洲国产婷婷香蕉久久久久久|