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

Yiner的ACM

成長的痕跡
<2011年2月>
303112345
6789101112
13141516171819
20212223242526
272812345
6789101112

統計

  • 隨筆 - 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 閱讀(226) 評論(0)  編輯 收藏 引用


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   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>
            国产色综合网| 亚洲大胆av| 性做久久久久久久免费看| 一本一本久久| 国产日韩欧美不卡在线| 久久免费精品日本久久中文字幕| 欧美在线视频在线播放完整版免费观看| 国产精品自在欧美一区| 久久久99免费视频| 美腿丝袜亚洲色图| 亚洲综合欧美| 欧美资源在线观看| 亚洲精品在线三区| 亚洲欧美日韩在线| 91久久精品一区二区三区| 9色精品在线| 国产亚洲福利一区| 亚洲国产日韩欧美在线99| 欧美视频免费在线| 免费日韩成人| 国产精品盗摄一区二区三区| 看欧美日韩国产| 欧美日韩日本视频| 麻豆久久婷婷| 欧美亚洲成人精品| 欧美黄色免费| 国产精品永久免费| 亚洲国产99| 韩日成人av| 一区二区三区欧美在线| 亚洲高清不卡av| 中文亚洲字幕| 日韩视频专区| 久久综合福利| 欧美一区在线看| 欧美日韩一卡| 亚洲成人自拍视频| 国产香蕉97碰碰久久人人| 亚洲狼人综合| 亚洲欧洲在线一区| 久久精品国产欧美激情| 亚洲男人av电影| 欧美寡妇偷汉性猛交| 美女福利精品视频| 国产毛片精品国产一区二区三区| 亚洲高清免费| 精品成人a区在线观看| 亚洲欧美成人| 亚洲永久精品国产| 欧美揉bbbbb揉bbbbb| 亚洲第一主播视频| 国内精品久久国产| 亚洲欧美日本另类| 亚洲综合电影一区二区三区| 欧美日韩第一页| 欧美国产日本| 亚洲欧洲视频在线| 免费观看久久久4p| 免播放器亚洲一区| 激情综合视频| 久久久久一区| 欧美成人午夜剧场免费观看| 国外精品视频| 久久久久国产精品厨房| 另类尿喷潮videofree | 亚洲免费av电影| 亚洲国产日韩一级| 欧美寡妇偷汉性猛交| 最近中文字幕日韩精品| av成人动漫| 欧美日韩视频| 亚洲免费中文字幕| 久久高清一区| 1204国产成人精品视频| 久久综合网色—综合色88| 欧美大尺度在线| 亚洲精品一区二区三区不| 欧美激情一区二区三区四区| 亚洲裸体视频| 亚洲欧美日韩国产综合精品二区| 国产精品羞羞答答| 久久不射中文字幕| 亚洲二区三区四区| 亚洲自拍偷拍视频| 国产欧美亚洲精品| 免费不卡中文字幕视频| 亚洲精品欧美日韩| 欧美在线播放视频| 亚洲国产mv| 欧美日韩一区二区精品| 午夜欧美大片免费观看| 欧美波霸影院| 亚洲欧美一区二区原创| 国内久久精品| 欧美日韩色一区| 校园激情久久| 亚洲人www| 久久精品国产免费观看| 亚洲精品国产精品久久清纯直播| 欧美日韩亚洲高清| 久久久久久久久久久久久9999| 亚洲经典视频在线观看| 先锋影院在线亚洲| 亚洲欧洲精品成人久久奇米网| 国产精品久久久久久久久婷婷| 久久精品一区| 正在播放亚洲| 亚洲国产精品t66y| 久久久国产精彩视频美女艺术照福利 | 亚洲日本理论电影| 久久精品国产亚洲精品| 一本色道久久88综合日韩精品| 国产日韩欧美亚洲| 欧美日韩在线高清| 久久久免费精品视频| 亚洲一区国产精品| 亚洲国产精品成人精品| 久久久国际精品| 亚洲午夜三级在线| 91久久国产综合久久| 国产一区激情| 国产精品网站一区| 欧美日韩在线观看一区二区三区| 久久午夜精品一区二区| 午夜在线精品偷拍| 在线视频中文亚洲| 亚洲免费观看高清在线观看| 欧美激情第10页| 欧美成人亚洲成人| 久久综合电影一区| 久久免费精品视频| 久久激情网站| 欧美一二三区精品| 午夜精品久久久久久久99水蜜桃 | 久久成人精品视频| 午夜国产精品视频免费体验区| 中国日韩欧美久久久久久久久| 日韩性生活视频| 亚洲精品网站在线播放gif| 最新日韩欧美| 亚洲精品影视| 99热精品在线| 在线亚洲精品| 亚洲欧美成人一区二区在线电影| 中日韩视频在线观看| 亚洲无限av看| 亚洲欧美日本另类| 欧美中文字幕不卡| 久久精品青青大伊人av| 久久永久免费| 欧美xx视频| 亚洲精品精选| 亚洲视频电影图片偷拍一区| 亚洲一区区二区| 先锋亚洲精品| 久久综合色播五月| 欧美成人免费大片| 欧美日韩性视频在线| 国产麻豆精品视频| 国内精品久久久久久久影视蜜臀| 国产亚洲精品bt天堂精选| 黄色欧美成人| 亚洲精品日韩在线| 亚洲小少妇裸体bbw| 久久黄色影院| 欧美福利一区| 一本综合久久| 欧美一区三区二区在线观看| 久久中文字幕一区二区三区| 欧美人与禽猛交乱配视频| 国产精品久久网站| 在线日韩精品视频| 一区二区免费在线视频| 久久精品一区二区三区四区| 欧美国产在线视频| 亚洲一区二区三区激情| 久久精品欧美日韩| 欧美日韩亚洲精品内裤| 国产亚洲a∨片在线观看| 亚洲精品久久久久久久久久久久久| 国产精品99久久久久久有的能看| 欧美一区国产二区| 亚洲国产精品一区二区第一页| 亚洲欧美久久| 久久亚洲精品网站| 国产精品性做久久久久久| 亚洲欧洲在线播放| 久久久另类综合| 国产精品99久久久久久白浆小说| 久久久激情视频| 国产精品美女久久久久久免费 | 国产精品视频99| 亚洲国产综合在线看不卡| 性欧美videos另类喷潮| 亚洲第一综合天堂另类专| 久久成人18免费观看| 国产精品v欧美精品v日本精品动漫| 亚洲国产精品成人综合色在线婷婷| 午夜精品视频| 亚洲精品美女免费|