参考自:https://www.cnblogs.com/ECJTUACM-873284962/p/6414173.html

The Famous Clock

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1399    Accepted Submission(s): 940

Problem Description
  Mr. B, Mr. G and Mr. M are now in Warsaw, Poland, for the 2012’s ACM-ICPC World Finals Contest. They’ve decided to take a 5 hours training every day before the contest. Also, they plan to start training at 10:00 each day since the World Final Contest will do so. The scenery in Warsaw is so attractive that Mr. B would always like to take a walk outside for a while after breakfast. However, Mr. B have to go back before training starts, otherwise his teammates will be annoyed. Here is a problem: Mr. B does not have a watch. In order to know the exact time, he has bought a new watch in Warsaw, but all the numbers on that watch are represented in Roman Numerals. Mr. B cannot understand such kind of numbers. Can you translate for him?
 

 

Input
  Each test case contains a single line indicating a Roman Numerals that to be translated. All the numbers can be found on clocks. That is, each number in the input represents an integer between 1 and 12. Roman Numerals are expressed by strings consisting of uppercase ‘I’, ‘V’ and ‘X’. See the sample input for further information.
 
Output
  For each test case, display a single line containing a decimal number corresponding to the given Roman Numerals.
 
Sample Input
I
II
III
IV
V
VI
VII
VIII
IX
X
XI
XII
Sample Output
Case 1: 1
Case 2: 2
Case 3: 3
Case 4: 4
Case 5: 5
Case 6: 6
Case 7: 7
Case 8: 8
Case 9: 9
Case 10: 10
Case 11: 11
Case 12: 12
 
 解法:
#include <bits/stdc++.h>
using namespace std;
int main(){
char s[];
int ans,k=;
while(gets(s)){
ans=;
int len=strlen(s);
for(int i=;i<len;i++){
if(s[i]=='I')ans++;
if(s[i]=='V')ans=-ans;
if(s[i]=='X')ans=-ans;
}
printf("Case %d: %d\n",++k,ans);
}
return ;
}

HDU 4256 翻译罗马数字的更多相关文章

  1. HDU 4256 The Famous Clock

    The Famous Clock Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  2. hdu 1075:What Are You Talking About(字典树,经典题,字典翻译)

    What Are You Talking About Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 102400/204800 K ...

  3. HDOJ/HDU 2352 Verdis Quo(罗马数字与10进制数的转换)

    Problem Description The Romans used letters from their Latin alphabet to represent each of the seven ...

  4. HDOJ/HDU 1075 What Are You Talking About(字符串查找翻译~Map)

    Problem Description Ignatius is so lucky that he met a Martian yesterday. But he didn't know the lan ...

  5. hdu 1075 What Are You Talking About 火星文翻译成英文

    What Are You Talking About Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 102400/204800 K ...

  6. hdu 3695:Computer Virus on Planet Pandora(AC自动机,入门题)

    Computer Virus on Planet Pandora Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 256000/1280 ...

  7. poj 2503:Babelfish(字典树,经典题,字典翻译)

    Babelfish Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 30816   Accepted: 13283 Descr ...

  8. HDU 1075 What Are You Talking About(Trie的应用)

    What Are You Talking About Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 102400/204800 K ...

  9. hdu 4998

    http://acm.hdu.edu.cn/showproblem.php?pid=4998 这道题,在比赛的时候看了很久,才明白题目的大意.都怪自己不好好学习英语.后来经过队友翻译才懂是什么意思. ...

随机推荐

  1. Tomcat搭建Web 应用服务器

    和安卓联合开发,测试手机设配效果,被安卓开发大神同事一顿鄙视之后,愤然而起自己搭建了一个本地服务器(愤怒 玻璃心使我成长~哈哈) java+tomcat安装 java安装 注册oracle账号: 手机 ...

  2. Linux提示删除文件cannot remove `文件名': Operation not permitted

    Linux系统下删除某个文件时提示如下报错: 执行lsattr命令可以看到隐藏属性-------i--------,如下图: 通过查找资料发现: chattr命令用于改变文件属性.这项指令可改变存放在 ...

  3. 微服务治理平台的RPC方案实现

    导读:本文主要探讨了rpc框架在微服务化中所处的位置,需要解决的问题.同时介绍了用友云微服务治理平台的rpc解决方案,为什么选择该方案.该方案提供的好处是什么.同时也会介绍用友RPC框架的基本结构以及 ...

  4. 【转】Word之表格、图片的题注(抬头)自动编号

    问:word中的表格怎么自动插入题注(即表头的编号自动编号)? 答: 1首先搞清楚自动编号的意思.自动插入题注的意思是,在你在word中新建或者复制一个word表格的时候,表头的编号就自动生成了,而不 ...

  5. PHP开发编码规范

    (转载:https://blog.csdn.net/alexdream/article/details/2213313) 这些年来多从事Linux下PHP和C相关的开发,带过很多项目和团队,下面是根据 ...

  6. 【Python3练习题 013】 求s=a+aa+aaa+aaaa+aa...a的值,其中a是一个数字

    a=input('输入数字>>>') count=int(input('几个数字相加>>>')) ret=[] for i in range(1,count+1): ...

  7. 项目中常用的MySQL 优化

    本文我们来谈谈项目中常用的MySQL优化方法,共19条,具体如下: 一.EXPLAIN 做MySQL优化,我们要善用EXPLAIN查看SQL执行计划. 下面来个简单的示例,标注(1.2.3.4.5)我 ...

  8. idea打包springboot+maven项目并发布在linux上

    2018年11月13日我亲测有效的,很简单的,借鉴博客:https://blog.csdn.net/smilecall/article/details/56288972 第一步:随便建一个maven类 ...

  9. Java-Spring-获取Request,Response对象

    转载自:https://www.cnblogs.com/bjlhx/p/6639542.html 第一种.参数 @RequestMapping("/test") @Response ...

  10. 如何通过stat获取目录或文件的权限的数字形式

    man stat 查看帮助. -c --format=FORMAT use the specified FORMAT instead of the default; output a new line ...