参考自: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[10];int ans,k=0;while(gets(s)){ans=0;int len=strlen(s);for(int i=0;i<len;i++){if(s[i]=='I')ans++;if(s[i]=='V')ans=5-ans;if(s[i]=='X')ans=10-ans;}printf("Case %d: %d\n",++k,ans);}return 0;
}

转载于:https://www.cnblogs.com/fangxiaoqi/p/10358516.html

HDU 4256 翻译罗马数字相关推荐

  1. # LeetCode集锦(四) - 第13题 Roman To Integer

    LeetCode集锦(四) - 第13题 Roman To Integer 问题 Roman numerals are represented by seven different symbols: ...

  2. 第八集 你明明自己也生病了,却还是要陪着我

    第八集 你明明自己也生病了,却还是要陪着我 TimeLimit:3000ms  MemoryLimit:256000KB 64-bit integer IO format:%lld Problem D ...

  3. HDU 4930 Fighting the Landlords(扯淡模拟题)

    Fighting the Landlords 大意: 斗地主....   分别给出两把手牌,肯定都合法.每张牌大小顺序是Y (i.e. colored Joker) > X (i.e. Blac ...

  4. HDU 1814 Peaceful Commission / HIT 1917 Peaceful Commission /CJOJ 1288 和平委员会(2-sat模板题)...

    HDU 1814 Peaceful Commission / HIT 1917 Peaceful Commission /CJOJ 1288 和平委员会(2-sat模板题) Description T ...

  5. 罗马数字转换成数字java_C趣味编程百例(31)将阿拉伯数字转换为罗马数字

    95.将阿拉伯数字转换为罗马数字 将大于0小于1000的阿拉伯数字转换为罗马数字.阿拉伯数字与罗马数字的对应关系如下: *问题分析与算法设计 题目中给出了阿拉伯数字与罗马数字的对应关系,题中的数字转换 ...

  6. 交互式图表_如何构建罗马数字转换器和交互式罗马数字图表

    交互式图表 The Roman numerals are no longer an essential part of our daily lives. But we do use them when ...

  7. hdu 过山车_从机械工程师到软件开发人员–我的编码过山车

    hdu 过山车 There aren't many people out there who grew up dreaming of writing code. I definitely didn't ...

  8. HDU 1048 [The Hardest Problem Ever] 字符串处理

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1048 题目大意:对一串字符串进行加密:每个英文字母变为字母表此后第五位,其他字符无变化.给出密码,要求 ...

  9. HDU 4383 To The Moon 解题报告

    HDU 4383 To The Moon 题意翻译 已知一个长为\(n\)的序列\(a\),你需要进行下面的四种操作. C l r d 将区间\([l,r]\)中的数加上\(d\),同时时间加\(1\ ...

最新文章

  1. ATS插件中配置文件自动更新思路
  2. 如何在一家内容公司,从零搭建起一支技术团队
  3. Firefox 66正式向广告宣战!预设禁止自动播放影片并加入加入 Windows Hello
  4. apollo芯片_ADAS/AD主控芯片研究:集成趋势下的短板与变革
  5. java面试题4(基础)
  6. 【干货】系统管理员必备,服务器监控工具汇总
  7. 奖学金pascal程序
  8. 建立主键应该遵循的原则
  9. AcWing 274. 移动服务
  10. 用java编写的一个迪杰斯特拉算法(单源最短路径算法,Dijkstra算法)。
  11. webpack如何将css文件分离的,webpack--css:Less文件的打包和分离(八)
  12. VSCode REMOTE SSH
  13. 编程必备的最基本5种算法思想
  14. 数字后端基本概念介绍Wire
  15. Win10专业版错误代码0xc0000225在吗修复?
  16. Calander用例
  17. 如何在线进行PDF文档压缩?
  18. Python爬虫之实现百度翻译
  19. 掌上智维隐私政策privacy
  20. N行M列每个位置放Aij个1厘米的正方体,求表面积

热门文章

  1. 自定义本地音乐播放器
  2. synchronized(二)
  3. 第三百六十二节,Python分布式爬虫打造搜索引擎Scrapy精讲—elasticsearch(搜索引擎)基本的索引和文档CRUD操作、增、删、改、查...
  4. 轻谈 return i++
  5. 代码实现把字符串反转
  6. git log 查看提交记录,参数:
  7. linux redhat 下命令行全部乱码解决
  8. python中如何快速判断一个值是否大于、小于、等于某个值?
  9. hibernate中的 bag
  10. 聚合中返回source_Java 8 中的 Streams API 详解—— Streams 的背景以及 Java 8 中的使用详解...