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

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| 久久资源av| 亚洲精品久久久一区二区三区| 欧美91精品| 欧美激情a∨在线视频播放| 99国产精品久久久| 亚洲视频视频在线| 国产日韩精品一区二区三区| 久久久久99精品国产片| 看欧美日韩国产| 亚洲精品影视在线观看| 一区二区冒白浆视频| 国产欧美在线观看一区| 欧美1区视频| 欧美日韩国产美女| 欧美中文字幕视频在线观看| 久久米奇亚洲| 在线视频亚洲一区| 亚洲伊人伊色伊影伊综合网| 韩日在线一区| 日韩视频永久免费观看| 国产一区99| 亚洲三级视频| 国内精品久久久久影院薰衣草| 欧美黄色片免费观看| 国产精品日韩欧美一区二区| 狂野欧美激情性xxxx| 欧美日韩综合| 久久午夜视频| 国产精品国产三级国产专播品爱网| 久久精品视频免费播放| 欧美精品激情在线| 久久久之久亚州精品露出| 欧美精品在欧美一区二区少妇| 亚洲欧美综合网| 欧美肥婆在线| 久久这里只有| 国产视频在线观看一区| 亚洲精品国产精品国产自| 狠狠色丁香婷婷综合| 亚洲女女女同性video| 亚洲精品免费电影| 久久夜色精品国产欧美乱极品| 香蕉久久一区二区不卡无毒影院| 欧美jizz19性欧美| 久久欧美肥婆一二区| 国产精品国产自产拍高清av王其| 欧美风情在线| 亚洲电影下载| 久久精品一区二区国产| 久久精品成人一区二区三区蜜臀| 欧美日韩午夜在线| 亚洲精品欧美日韩专区| 亚洲国产日韩在线| 久久综合狠狠| 老鸭窝毛片一区二区三区| 国产一区二区三区黄| 午夜国产精品视频| 香蕉成人伊视频在线观看| 欧美午夜电影完整版| 亚洲三级国产| 亚洲天堂av综合网| 欧美日韩在线电影| 日韩亚洲欧美成人一区| 亚洲视频在线播放| 欧美色网在线| 亚洲一区二区三区在线视频| 亚洲一区成人| 国产精品人成在线观看免费| 中国女人久久久| 午夜精品久久99蜜桃的功能介绍| 国产精品国产三级国产普通话99| 一区二区三区回区在观看免费视频| 一区二区三区四区五区视频 | 裸体歌舞表演一区二区| 狠狠v欧美v日韩v亚洲ⅴ| 久久久91精品国产| 欧美顶级艳妇交换群宴| 亚洲欧洲日夜超级视频| 欧美日韩国产欧| 亚洲一区二区三区三| 久久丁香综合五月国产三级网站| 国产婷婷色一区二区三区| 久久精品视频亚洲| 欧美激情精品久久久久久大尺度| 91久久久国产精品| 欧美日韩午夜视频在线观看| 亚洲欧美视频| 老司机精品视频网站| 亚洲欧洲三级| 国产麻豆日韩| 免费在线看成人av| 亚洲一区国产| 免费人成精品欧美精品| 中文精品视频| 国产综合在线看| 欧美日韩国产一中文字不卡| 亚洲欧美在线免费| 亚洲国产精品一区二区www| 亚洲一区在线看| 伊人色综合久久天天| 欧美精品在线观看播放| 欧美一区二区三区四区视频| 亚洲国产欧美在线| 欧美一区二区成人| 亚洲日本理论电影| 国产亚洲制服色| 欧美日韩免费在线| 久久精品视频va| 中文国产成人精品| 亚洲第一中文字幕在线观看| 亚洲欧美一区二区三区极速播放| 在线日韩av片| 国产伦精品一区二区三区视频孕妇 | 香蕉亚洲视频| 亚洲久久成人| 欧美成人中文字幕| 久久久夜夜夜| 欧美一级久久| 亚洲主播在线播放| 在线亚洲精品| 亚洲美女中文字幕| 亚洲大胆女人| 国内精品福利| 国产午夜精品久久久久久久| 欧美日韩日本国产亚洲在线| 美女黄毛**国产精品啪啪| 欧美一区在线直播| 亚洲一区二区黄| 9l国产精品久久久久麻豆| 亚洲国产成人av在线| 蜜臀久久久99精品久久久久久| 久久爱另类一区二区小说| 午夜精品免费视频| 亚洲欧美日本国产专区一区| 中文亚洲欧美| 亚洲视频www| 亚洲欧美日韩国产综合在线 | 激情久久五月| 国产一区二区三区久久| 国产精品亚发布| 国产欧美日韩激情| 国产日韩精品一区二区| 国产女同一区二区| 国产日韩欧美高清免费| 国产亚洲欧美一区| 国产最新精品精品你懂的| 国产午夜亚洲精品羞羞网站| 国产伦精品一区二区三区视频孕妇| 国产精品伦理| 国产在线视频欧美一区二区三区| 国产欧美一区二区精品婷婷| 国产日本亚洲高清| 激情五月婷婷综合| 在线免费一区三区| 亚洲精品在线三区| 亚洲视频1区| 欧美伊人久久| 美女精品在线| 亚洲啪啪91| 亚洲一区二区三| 久久精品九九| 美女91精品| 欧美日韩综合| 国产综合色精品一区二区三区| 亚洲大黄网站| 亚洲先锋成人| 久久人人爽国产| 亚洲激情在线激情| 香蕉久久a毛片| 欧美寡妇偷汉性猛交| 欧美视频免费| 亚洲成在线观看| 亚洲线精品一区二区三区八戒| 欧美在线3区| 亚洲黄色影院| 先锋影音久久久| 欧美精品二区| 一区二区在线观看视频| 日韩视频在线观看| 久久久久久亚洲综合影院红桃 | 9l国产精品久久久久麻豆| 亚洲欧美综合一区| 欧美精品在线观看91| 国产日韩专区| 亚洲影院色在线观看免费| 久久综合久久综合九色| 日韩视频免费观看高清在线视频 | 一本一本久久a久久精品牛牛影视| 亚洲欧美日韩国产| 欧美电影免费观看高清| 国产在线观看精品一区二区三区| 夜夜躁日日躁狠狠久久88av| 久热精品在线| 亚洲在线网站| 欧美亚州在线观看| 亚洲毛片播放|