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

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 閱讀(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>
            国产精品高清网站| 一区二区三区日韩欧美| 亚洲精品偷拍| 韩国一区电影| 一区二区三区免费看| 91久久国产综合久久蜜月精品 | 午夜精品免费| 欧美高清免费| 蜜臀久久99精品久久久久久9 | 国产麻豆精品theporn| 亚洲国产精品传媒在线观看| 国产欧美一区二区三区视频| 99精品国产在热久久婷婷| 91久久精品美女高潮| 久久国产精品久久久| 久久激情一区| 国产日韩欧美一二三区| 亚洲一区二区三区精品视频| 一本色道婷婷久久欧美| 欧美成人午夜激情在线| 欧美成人激情视频| 伊人久久男人天堂| 久久米奇亚洲| 欧美成人福利视频| 亚洲高清电影| 欧美a级片一区| 亚洲精品一区在线观看| 日韩视频二区| 欧美日韩免费一区| 一区二区三区国产盗摄| 亚洲男人的天堂在线aⅴ视频| 欧美揉bbbbb揉bbbbb| 中文在线资源观看网站视频免费不卡 | 欧美欧美天天天天操| 亚洲国产一区二区三区青草影视| 最新中文字幕亚洲| 欧美精品日本| 国产精品99久久久久久www| 亚洲一二三区在线| 国产精品美女久久久免费 | 一区二区欧美日韩视频| 亚洲你懂的在线视频| 国产欧美精品一区aⅴ影院| 亚洲欧美国产77777| 久久精品欧美日韩精品| 亚洲激情六月丁香| 欧美久久久久久久| 亚洲自拍三区| 久久五月婷婷丁香社区| 亚洲精品精选| 国产精品毛片在线| 久久天天躁夜夜躁狠狠躁2022| 欧美黑人多人双交| 亚洲午夜av电影| 国产一区二区三区免费观看| 欧美成人dvd在线视频| 一本久久a久久免费精品不卡| 欧美在线视频二区| 亚洲国产精品久久久久| 国产精品红桃| 免费观看成人| 亚洲午夜久久久| 免费在线成人| 亚洲欧美日韩在线| 136国产福利精品导航网址应用 | 欧美电影免费网站| 日韩一级黄色大片| 久久中文字幕一区| 一区二区三区精品在线| 国产日韩在线看片| 欧美日韩成人综合| 欧美在线亚洲在线| 亚洲国产一成人久久精品| 欧美一级专区免费大片| 亚洲国产欧美一区二区三区丁香婷| 欧美日韩情趣电影| 久久久亚洲综合| 亚洲一级片在线观看| 欧美黄色日本| 久久蜜臀精品av| 午夜精品在线观看| 一二三四社区欧美黄| 激情综合久久| 国产精品视频内| 欧美日韩国产在线播放| 六十路精品视频| 欧美一级网站| 亚洲午夜av| 一区二区三区欧美在线观看| 亚洲黄色av一区| 噜噜噜躁狠狠躁狠狠精品视频| 一区二区三区欧美成人| 欧美成人精品福利| 久久九九电影| 欧美中文字幕不卡| 亚洲一区二区三区在线看| 亚洲久久一区| 亚洲精品一区二区三区蜜桃久| 伊人狠狠色j香婷婷综合| 国产永久精品大片wwwapp| 国产精品久99| 欧美性色视频在线| 欧美日韩免费一区二区三区| 欧美伦理a级免费电影| 免费久久99精品国产| 玖玖玖免费嫩草在线影院一区| 久久大逼视频| 久久久久久婷| 玖玖玖国产精品| 欧美不卡高清| 欧美精品一区二区三区高清aⅴ| 欧美超级免费视 在线| 欧美~级网站不卡| 欧美/亚洲一区| 欧美日韩成人在线| 欧美午夜视频网站| 国产精品美女主播| 国产欧美一区二区三区国产幕精品| 国产精品爽黄69| 国产自产女人91一区在线观看| 国产真实精品久久二三区| 韩国自拍一区| 亚洲欧洲三级| 亚洲欧美99| 久久久精品国产免费观看同学| 久久在线视频| 亚洲国产人成综合网站| 亚洲免费播放| 午夜欧美精品| 久久综合给合| 欧美午夜精品久久久久久久| 国产伦精品一区二区三区| 国内成+人亚洲| 亚洲日本乱码在线观看| 亚洲永久精品大片| 久久国产精品一区二区三区四区| 久久这里只精品最新地址| 亚洲福利在线视频| 一区二区三区视频观看| 欧美一区二区三区男人的天堂| 久久久久久亚洲精品杨幂换脸| 欧美成人免费全部| 国产精品美女久久久久久久| 一区免费观看视频| 在线视频你懂得一区| 久久久久久999| 亚洲精品小视频| 欧美资源在线| 欧美午夜大胆人体| 影音先锋中文字幕一区| 在线亚洲激情| 你懂的网址国产 欧美| 99天天综合性| 老司机精品视频一区二区三区| 国产精品v欧美精品v日韩| 伊人成人在线视频| 亚洲欧美日韩综合aⅴ视频| 欧美成人国产一区二区| 亚洲一区二区成人在线观看| 欧美sm视频| 精品69视频一区二区三区| 亚洲一区二区在线视频| 欧美成人精品福利| 欧美专区在线观看| 国产精品乱码人人做人人爱| 亚洲精品一区二区三区樱花| 久久国产手机看片| 亚洲毛片在线免费观看| 久久青青草综合| 国产日韩欧美夫妻视频在线观看| 一区二区三区.www| 蜜臀a∨国产成人精品| 午夜精品久久| 国产精品久久一卡二卡| 亚洲乱码日产精品bd| 欧美jizz19性欧美| 久久精品国产第一区二区三区| 国产精品久久久亚洲一区| 99综合在线| 亚洲人成人一区二区在线观看| 久久亚洲电影| 韩国成人福利片在线播放| 性欧美1819sex性高清| 一区二区三欧美| 欧美日韩一级黄| 亚洲最新视频在线| 亚洲国产欧美一区二区三区丁香婷| 久久青草欧美一区二区三区| 韩国av一区二区三区| 久久蜜桃资源一区二区老牛| 欧美亚洲日本网站| 国产亚洲欧美日韩在线一区| 欧美在线观看一区二区| 亚洲欧美国产77777| 国产精品成人播放| 亚洲欧美日韩综合一区| 亚洲自拍偷拍一区| 国产日韩欧美一区在线| 久久在线精品| 美女久久网站|