NYOJ--484 The Famous Clock

2024-08-27 03:32
文章标签 nyoj 484 famous clock

本文主要是介绍NYOJ--484 The Famous Clock,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

The Famous Clock

时间限制: 1000 ms  |  内存限制: 65535 KB
难度: 1
描述

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?

输入
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.
输出
For each test case, display a single line containing a decimal number corresponding to the given Roman Numerals.
样例输入
I
II
III
IV
V
VI
VII
VIII
IX
X
XI
XII
样例输出
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
来源
HDU
#include<cstdio>
#include <iostream>
#include <string.h>
using namespace std;
int main()
{char NIUBI[5];int i = 0, t = 0;while (cin>>NIUBI){if (strcmp(NIUBI, "I") == 0) t = 1;else if (strcmp(NIUBI, "II") == 0) t = 2;else if (strcmp(NIUBI, "III") == 0) t = 3;else if (strcmp(NIUBI, "IV") == 0) t = 4;else if (strcmp(NIUBI, "V") == 0) t = 5;else if (strcmp(NIUBI, "VI") == 0) t = 6;else if (strcmp(NIUBI, "VII") == 0) t = 7;else if (strcmp(NIUBI, "VIII") == 0) t = 8;else if (strcmp(NIUBI, "IX") == 0) t = 9;else if (strcmp(NIUBI, "X") == 0) t = 10;else if (strcmp(NIUBI, "XI") == 0) t = 11;else if (strcmp(NIUBI, "XII") == 0) t = 12;printf("Case %d: %d\n",++i,t);}return 0;
}
字符比较。

这篇关于NYOJ--484 The Famous Clock的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1110513

相关文章

nyoj 288 士兵杀敌(五)

一道插线问线离线版的题  复杂度O(n); 代码如下: #include<stdio.h>#include<string.h>const int M = 1000003;const int mod=10003;int num[M];int main(){int n,c,q;scanf("%d%d%d",&n,&c,&q);while(c--){int a,b,x;scan

nyoj 1037 Postscript of Tian Ji racing

一道卡贪心的题。 也算一道改编题。 此题的解法推荐为二分图的最大匹配。 首先将输入数据转换一下,然后将满足题意的一组牌建立条边,最终边的覆盖数即为 LN 最后可得的分数。 然后求出最大匹配即可。 代码如下: #include<stdio.h>#include<string.h>char card[30][5];char s[5];int map[30][30];

nyoj 1002 Trucking

同样一道改编题。 只要把题意理解了好。 简单的二分加最短路。 只要二分高度, 然后求最短路,输出满足题意的即可。 代码如下: (最短路用spfa 时间效率高) #include <iostream>#include <cstdio>#include <cstring>#include <ctime>#include <queue>using namespace st

nyoj 1072 我想回家

一道相当题目描述相当扯的题。 这道题目的描述最后说的是求出到达最后一个点的最短距离,所以输入数据最后输入的城堡的坐标是没用的。 就是先求出两点之间的距离,若不大于村落间距离,并且不大于最后的距离限制 l ,则在两点间建边。 最后任意方法求出最短路即可。 #include <iostream>#include<stdio.h>#include<vector>#include<

nyoj 1038 纸牌游戏

poj 的一道改编题,说是翻译题更恰当,因为只是小幅度改动。 一道模拟题,代码掌控能力比较好,思维逻辑清晰的话就能AC。 代码如下: #include<stdio.h>#include<string.h>#include<algorithm>using namespace std;struct node{char c[5];int rk;char da[5];int nu

nyoj 685 查找字符串

当初一开始没做出来。 后来,学习过一段时间之后,在返回来做这道题,忽然发现,map类容器可以做。 PS:需要注意的是:此题如果用c++的输入输出的话,会超时。 O(time):gets()<  scanf() < cin。   附上代码: #include<stdio.h>#include<map>#include<string>#include<string.h>usin

nyoj 695 Judging Filling Problems

一道强大的模拟题。。。 只要学会<string>类的运用即可。。。 注意: 1、细节的处理。 2、问题的分情况讨论。。 附上代码: 有好对缀余的地方,希望大神前来更新。 #include<stdio.h>#include<string.h>#include<string>#include<iostream>using namespace std;int num[1000

NYOJ 37 回文字符串(记忆化搜索)

OJ题目 : 戳这里~~ 描述 所谓回文字符串,就是一个字符串,从左到右读和从右到左读是完全一样的,比如"aba"。当然,我们给你的问题不会再简单到判断一个字符串是不是回文字符串。现在要求你,给你一个字符串,可在任意位置添加字符,最少再添加几个字符,可以使这个字符串成为回文字符串。 输入 第一行给出整数N(0<N<100) 接下来的N行,每行一个字符串,每个字符串长度不超过1000.

NYOJ 763 Vawio Sequence

OJ题目 : 戳这里~ 描述 Vawio Sequence is very funny,it is a sequence of integers. It has some interesting properties. ·   Vawio is of odd length i.e. L = 2*n + 1. ·  The first (n+1) integers of  Vawio s

NYOJ 10 skiing

OJ题目 : 猛戳~~ 描述 Michael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你。Michael想知道载一个区域中最长底滑坡。区域由一个二维数组给出。数组的每个数字代表点的高度。下面是一个例子  1 2 3 4 5 16 17 18 19 6 15 24 25 20 7 14