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
Source
分析:这种Case的模式不太会写,然后我直接枚举出来,WA了,我也不知道为啥错了,然后看别人写,去统计,感觉自己好傻,根本没必要那样!
下面给出AC代码:
 #include <bits/stdc++.h>
using namespace std;
int main()
{
char s[];
int k=;
int ans;
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 The Famous Clock的更多相关文章

  1. ACM The Famous Clock

    The Famous Clock 时间限制:1000 ms  |  内存限制:65535 KB 难度:1   描述 Mr. B, Mr. G and Mr. M are now in Warsaw, ...

  2. HDU 4256 翻译罗马数字

    参考自:https://www.cnblogs.com/ECJTUACM-873284962/p/6414173.html The Famous Clock Time Limit: 2000/1000 ...

  3. nyoj 484-The Famous Clock

    484-The Famous Clock 内存限制:64MB 时间限制:1000ms 特判: No 通过数:2 提交数:2 难度:1 题目描述: Mr. B, Mr. G and Mr. M are ...

  4. hdu 4255 A Famous Grid

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4255 A Famous Grid Description Mr. B has recently dis ...

  5. HDU 4253 Two Famous Companies

    Two Famous Companies Time Limit: 15000ms Memory Limit: 32768KB This problem will be judged on HDU. O ...

  6. HDU 4251 The Famous ICPC Team Again 主席树

    The Famous ICPC Team Again Problem Description   When Mr. B, Mr. G and Mr. M were preparing for the ...

  7. HDU 4294 A Famous Equation(DP)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4249 题目大意:给一个a+b=c的表达式,但是a.b.c中部分位的数字丢失,并用?代替,问有多少种方案 ...

  8. HDU 4248 A Famous Stone Collector 组合数学dp ****

    A Famous Stone Collector Time Limit: 30000/15000 MS (Java/Others)    Memory Limit: 32768/32768 K (Ja ...

  9. HDU 4251 The Famous ICPC Team Again(划分树)

    The Famous ICPC Team Again Time Limit: 30000/15000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

随机推荐

  1. webstorm安装express报错

    .... Exit code: -1 解决方法: webstorm创建express 需要 预先安装express-generator npm install express-generator -g

  2. 用于ARM上的FFT与IFFT源代码(C语言,不依赖特定平台)(转)

    源:用于ARM上的FFT与IFFT源代码(C语言,不依赖特定平台) 代码在2011年全国电子大赛结束后(2011年9月3日)发布,多个版本,注释详细. /*********************** ...

  3. Memcached源码分析之请求处理(状态机)

    作者:Calix 一)上文 在上一篇线程模型的分析中,我们知道,worker线程和主线程都调用了同一个函数,conn_new进行事件监听,并返回conn结构体对象.最终有事件到达时,调用同一个函数ev ...

  4. C#中的逆变和协变

    msdn 解释如下: “协变”是指能够使用与原始指定的派生类型相比,派生程度更大的类型. “逆变”则是指能够使用派生程度更小的类型. 解释的很正确,大致就是这样,不过不够直白. 直白的理解: “协变” ...

  5. IOS开发根据字体大小等获取文字所占的高度

    Model *model = self.modelArr[indexPath.row]; //根据label文字获取CGRect NSMutableParagraphStyle *paragraphS ...

  6. 好的 vim编辑博客

    http://www.cnblogs.com/ma6174/archive/2011/12/10/2283393.html 如果你不满足于使用现成的颜色主题的话,那我们来看一下如何修改环境配色.首先要 ...

  7. Linux命令之文件处理

    文件处理命令 1.dirname命令 dirname命令去除文件名中的非目录部分,仅显示与目录有关的内容.dirname命令读取指定路径名保留最后一个/及其后面的字符,删除其他部分,并写结果到标准输出 ...

  8. jdk1.8中的for循环

    jdk1.8 从语法角度,感觉发生的变化还是蛮大的.在此记录一下. for 循环 public static void main(String[] args) { List<Animal> ...

  9. iOS 之 获取View所在控制器

    1. UIResponder UIViewController *uvc; UIResponder* nextResponder = [self.superview.superview.supervi ...

  10. 在delphi中,DLL加载时做初始化的Demo

    library DLLEntry;//dll源码 uses SysUtils, Classes, Dialogs, Windows; {$R *.res} procedure DLLEntryPoin ...