#include <iostream>
#include <string>
#define MAXN 26 using namespace std; int _map[MAXN]; string fun(int sum); int main()
{
//freopen("acm.acm","r",stdin);
int test;
int i;
string s_1;
string s_2;
int sum_1;
int sum_2;
int sum;
_map['m'-'a'] = ;
_map['c'-'a'] = ;
_map['x'-'a'] = ;
_map['i'-'a'] = ;
cin>>test;
while(test --)
{
cin>>s_1>>s_2;
sum_1 = ;
sum_2 = ;
for(i = ; i < s_1.length(); ++ i)
{ if(s_1[i] >= '' && s_1[i] <= '')
{
++ i;
sum_1 += (s_1[i-]-'')*_map[s_1[i]-'a'];
}
else
{
sum_1 += _map[s_1[i]-'a'];
}
}
for(i = ; i < s_2.length(); ++ i)
{
if(s_2[i] >= '' && s_2[i] <= '')
{
++ i;
sum_2 += (s_2[i-]-'')*_map[s_2[i]-'a'];
}
else
{
sum_2 += _map[s_2[i]-'a'];
}
}
//cout<<sum_1<<" "<<sum_2<<endl;
sum = sum_1 + sum_2;
cout<<fun(sum)<<endl;
}
} string fun(int sum)
{
string s;
int num_m;
int num_c;
int num_x;
int num_i;
num_m = sum/;
sum %= ;
num_c = sum/;
sum %= ;
num_x = sum/;
sum %= ;
num_i = sum;
if(num_m != )
{
if(num_m == )
{
s += 'm';
}
else
{
s += char(num_m + '');
s += 'm';
}
}
if(num_c != )
{
if(num_c == )
{
s += 'c';
}
else
{
s += char(num_c + '');
s += 'c';
}
} if(num_x != )
{
if(num_x == )
{
s += 'x';
}
else
{
s += char(num_x + '');
s += 'x';
}
} if(num_i != )
{
if(num_i == )
{
s += 'i';
}
else
{
s += char('' + num_i);
s += 'i';
}
}
return s;
}

POJ 2685的更多相关文章

  1. POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理

    Halloween treats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7644   Accepted: 2798 ...

  2. POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理

    Find a multiple Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7192   Accepted: 3138   ...

  3. POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治

    The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22286 ...

  4. POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法

    Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 37427   Accepted: 16288 Descr ...

  5. POJ 3254. Corn Fields 状态压缩DP (入门级)

    Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9806   Accepted: 5185 Descr ...

  6. POJ 2739. Sum of Consecutive Prime Numbers

    Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050 ...

  7. POJ 2255. Tree Recovery

    Tree Recovery Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11939   Accepted: 7493 De ...

  8. POJ 2752 Seek the Name, Seek the Fame [kmp]

    Seek the Name, Seek the Fame Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 17898   Ac ...

  9. poj 2352 Stars 数星星 详解

    题目: poj 2352 Stars 数星星 题意:已知n个星星的坐标.每个星星都有一个等级,数值等于坐标系内纵坐标和横坐标皆不大于它的星星的个数.星星的坐标按照纵坐标从小到大的顺序给出,纵坐标相同时 ...

随机推荐

  1. Le Chapitre X

    Il se trouvait dans la région des astéroïdes 325, 326, 327, 328, 329 et 330. Il commença donc par le ...

  2. (2)The secrets of learning a new language

    https://www.ted.com/talks/lydia_machova_the_secrets_of_learning_a_new_language/transcript 00:13I lov ...

  3. Codeforces Round #520 (Div. 2) E. Company(dfs序判断v是否在u的子树里+lca+线段树)

    https://codeforces.com/contest/1062/problem/E 题意 给一颗树n,然后q个询问,询问编号l~r的点,假设可以删除一个点,使得他们的最近公共祖先深度最大.每次 ...

  4. C++ 中 new 操作符内幕:new operator、operator new、placement new

    一.new 操作符(new operator) 人们有时好像喜欢有益使C++语言的术语难以理解.比方说new操作符(new operator)和operator new的差别. 当你写这种代码: st ...

  5. C++STL deque

    deque双端数组 deque<int> dq; deque<int>::iterator it; dq.push_back();//尾部插入元素 dq.push_front( ...

  6. Excel2007VBA数组和工作表及单元格的引用

    动态数组使用: https://zhidao.baidu.com/question/1432222709706721499.html 使用Redim动态数组即可. 1 2 3 4 5 6 7 8 Su ...

  7. chmod用法

    以下是chmod的详细用法:chmod命令用于改变linux系统文件或目录的访问权限.用它控制文件或目录的访问权限.该命令有两种用法.一种是包含字母和操作符表达式的文字设定法:另一种是包含数字的数字设 ...

  8. php 正则截取文章图片

    preg_match ("<img.*src=[\"](.*?)[\"].*?>",$test,$match); //获取图片 echo $matc ...

  9. java 定时执行

    Timer和TimerTask CountDownTimer (android)

  10. (转)在.NET程序运行过程中,什么是堆,什么是栈?什么情况下会在堆(栈)上分配数据?它们有性能上的区别吗?“结构”对象可能分配在堆上吗?什么情况下会发生,有什么需要注意的吗?

    转自:http://www.cnblogs.com/xiaoyao2011/archive/2011/09/09/2172427.html 在.NET程序运行过程中,什么是堆,什么是栈? 堆也就是托管 ...