POJ 2685
#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的更多相关文章
- POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理
Halloween treats Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7644 Accepted: 2798 ...
- POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理
Find a multiple Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7192 Accepted: 3138 ...
- POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治
The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22286 ...
- POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法
Flip Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 37427 Accepted: 16288 Descr ...
- POJ 3254. Corn Fields 状态压缩DP (入门级)
Corn Fields Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9806 Accepted: 5185 Descr ...
- POJ 2739. Sum of Consecutive Prime Numbers
Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20050 ...
- POJ 2255. Tree Recovery
Tree Recovery Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11939 Accepted: 7493 De ...
- 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 ...
- poj 2352 Stars 数星星 详解
题目: poj 2352 Stars 数星星 题意:已知n个星星的坐标.每个星星都有一个等级,数值等于坐标系内纵坐标和横坐标皆不大于它的星星的个数.星星的坐标按照纵坐标从小到大的顺序给出,纵坐标相同时 ...
随机推荐
- B-论文一些好的句子
Due to high design and test costs for real many-core chips, simulators which allow exploring the bes ...
- PHP函数gmstrftime()将秒数转换成天时分秒
http://yangjunwei.com/a/930.html PHP函数gmstrftime()将秒数转换成天时分秒 一个应用场景需要用到倒计时的时分秒,比如新浪微博授权有效期剩余: 7天16 ...
- application.properties /application.yml官网查看配置;springboot application.properties 官网查看,info yml 查看;springboot.yml查看info;springboot.yml查看Actuator监控中心info
官网查看: https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#appendix 查看info ...
- 新建maven遇到的错误
新建一个maven,遇到错误如下: Description Resource Path Location Type Dynamic Web Module 3.0 requires Java 这时候,只 ...
- adb 调试出现问题
用adb shell时出现error: insufficient permissions for device 在终端输入 sudo -s adb kill-server adb start-serv ...
- sas和ssd盘写入数据效率对比
表结构如下: CREATE TABLE `tab_AAA` ( `id` bigint(20) NOT NULL AUTO_INCREMENT , `customer_no` varchar(32 ...
- 开发.Net Script 模板-MyGeneration (翻译)
原文信息 原文地址 原文作者信息 Justin Greenwood MyGeneration Software http://www.mygenerationsoftware.com/ October ...
- 给Java开发者的Scala教程
author:Michel Schinz,Philipp Haller 1. 简介 本文将该要的介绍Scala语言和其编译.这里假设读者已经有一定的java开发经验,需要概要的了解他们可以用Scala ...
- VS SVN
AnkhSVN - Subversion Support for Visual Studio 直接包管理中就可以安装 VS2015和SVN合作 Visual Studio 添加SVN插件 Ank ...
- 13.2.DataGrid增、删、改、查后台实现
一.UserServlet: 二:Dao接口: 三:Dao接口的实现类: