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

Yiner的ACM

成長(zhǎng)的痕跡
<2011年3月>
272812345
6789101112
13141516171819
20212223242526
272829303112
3456789

統(tǒng)計(jì)

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

常用鏈接

留言簿(1)

隨筆分類

隨筆檔案

搜索

  •  

最新評(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 閱讀(226) 評(píng)論(0)  編輯 收藏 引用


只有注冊(cè)用戶登錄后才能發(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>
            久久在线精品| 欧美日韩综合视频网址| 久久亚洲精品欧美| 久久亚洲春色中文字幕| 欧美xxx成人| 欧美日韩福利视频| 国产精品久99| 国产亚洲精品久久久久动| 国内精品久久久久久久影视麻豆 | 一区二区三区欧美成人| 一本色道久久综合狠狠躁篇怎么玩 | 久久精品国产999大香线蕉| 欧美专区亚洲专区| 久久久亚洲高清| 欧美国产精品专区| 欧美午夜精品理论片a级按摩| 国产精品午夜av在线| 国产一区自拍视频| 亚洲人成毛片在线播放女女| 一本色道久久精品| 久久av一区二区三区亚洲| 久久视频在线看| 91久久在线视频| 亚洲一区二区av电影| 久久成人一区| 欧美国产91| 国产精品视频在线观看| 精品电影一区| 一区二区欧美在线观看| 欧美在线视频一区二区| 欧美xxx成人| 制服丝袜激情欧洲亚洲| 久久精品中文字幕免费mv| 欧美岛国在线观看| 国产精品日韩久久久| 伊人男人综合视频网| 中日韩美女免费视频网址在线观看| 欧美一区激情| 亚洲国产婷婷香蕉久久久久久| 亚洲一卡二卡三卡四卡五卡| 久久xxxx| 欧美特黄一区| 亚洲丰满在线| 午夜在线一区| 亚洲欧洲一区二区在线观看| 午夜精品美女久久久久av福利| 久久综合999| 国产毛片一区二区| 日韩一级在线观看| 久久日韩粉嫩一区二区三区| 一区二区久久久久| 免费日韩成人| 黑人一区二区三区四区五区| 亚洲天堂av电影| 欧美激情精品久久久久久变态| 午夜精品久久久久久久蜜桃app | 亚洲视频在线观看视频| 美女精品一区| 性色av一区二区三区在线观看 | 国产精品免费视频观看| 亚洲激情综合| 久久免费国产精品| 亚洲女爱视频在线| 欧美日韩激情网| 亚洲国产精品美女| 久久青青草综合| 亚洲一级免费视频| 欧美视频免费| 一本色道久久综合狠狠躁篇的优点 | 欧美va亚洲va香蕉在线| 国内揄拍国内精品久久| 亚洲欧美成人网| 亚洲精品在线电影| 欧美激情1区| 91久久久在线| 欧美成人精品影院| 欧美在线观看www| 国产伦精品一区二区三区| 亚洲自拍电影| 亚洲最新合集| 欧美网站在线观看| 在线性视频日韩欧美| 亚洲日本中文字幕免费在线不卡| 老司机67194精品线观看| 激情成人综合| 美女视频一区免费观看| 欧美中文日韩| 一区二区三区在线免费播放| 久久久久一区二区三区四区| 欧美一级二级三级蜜桃| 国产亚洲在线观看| 久久美女艺术照精彩视频福利播放| 午夜欧美大片免费观看| 国产一区二区三区四区五区美女 | 亚洲日本视频| 亚洲激情另类| 欧美区亚洲区| 亚洲影院污污.| 亚洲一区欧美二区| 国产视频在线一区二区| 久久久亚洲欧洲日产国码αv| 久久爱另类一区二区小说| 黄色精品一区二区| 欧美第一黄网免费网站| 欧美成年人视频网站| 99视频精品全部免费在线| 亚洲精品一区二区三区婷婷月| 欧美日韩一区二区三区免费看| 亚洲一区二区在线看| 亚洲在线电影| 国模私拍视频一区| 欧美成人伊人久久综合网| 免费在线欧美黄色| 亚洲色在线视频| 亚洲欧美激情视频在线观看一区二区三区| 国产精品综合久久久| 久久深夜福利| 欧美护士18xxxxhd| 亚洲男人第一网站| 久久成人18免费网站| 亚洲国产一区视频| 99热这里只有精品8| 国产日韩av高清| 欧美成人性生活| 欧美肉体xxxx裸体137大胆| 欧美一区二区视频在线| 久久综合久色欧美综合狠狠| 夜夜嗨av一区二区三区中文字幕 | 91久久精品日日躁夜夜躁欧美 | 国产综合色在线视频区| 欧美韩日高清| 国产精品草草| 免费日韩一区二区| 欧美性大战xxxxx久久久| 久久激情五月激情| 免费一区视频| 午夜精品影院| 欧美成人蜜桃| 久久精品国产精品亚洲精品| 免费精品99久久国产综合精品| 亚洲一区影音先锋| 久久久精品国产99久久精品芒果| 夜夜嗨一区二区| 久久se精品一区二区| 一区二区三区免费在线观看| 久久国产精品久久久| 在线一区二区三区四区五区| 久久精品国产亚洲一区二区| 亚洲丝袜av一区| 老司机午夜免费精品视频| 欧美噜噜久久久xxx| 久久av红桃一区二区小说| 欧美国产免费| 久久亚洲一区| 亚洲人成网站777色婷婷| 中文国产成人精品| 亚洲激情在线观看| 亚洲欧美另类综合偷拍| 亚洲精品一区在线| 欧美一区二区三区在线| 一区二区三区|亚洲午夜| 久久综合久久综合久久综合| 亚洲欧美精品在线观看| 欧美承认网站| 女女同性精品视频| 国产精品一级| 亚洲最黄网站| 99精品久久免费看蜜臀剧情介绍| 久久久国产一区二区三区| 午夜激情综合网| 欧美视频官网| 亚洲精品护士| 亚洲日本中文字幕免费在线不卡| 欧美尤物一区| 欧美一区二区高清| 欧美性开放视频| 亚洲六月丁香色婷婷综合久久| 亚洲高清网站| 久久久噜噜噜久久中文字幕色伊伊 | 一区二区三区在线观看国产| 亚洲欧美日韩国产一区二区| 亚洲性av在线| 欧美另类亚洲| 亚洲日本va午夜在线电影| 亚洲第一伊人| 久久在线视频在线| 玖玖综合伊人| 国内精品久久久久久久97牛牛| 亚洲欧美日本日韩| 欧美亚洲一区三区| 国产精品拍天天在线| 亚洲视频图片小说| 亚洲一区二区网站| 欧美午夜一区二区| 一区二区动漫| 欧美一级片在线播放| 国产精品久久久久久久第一福利| 一区二区高清视频在线观看| 亚洲一区二区黄| 国产精品久久影院|