http://acm.hdu.edu.cn/showproblem.php?pid=4245点击打开链接
http://acm.hdu.edu.cn/showproblem.php?pid=4256点击打开链接
A Famous Music Composer
Problem Description
Mr. B is a famous music composer. One of his most famous work was his set of preludes. These 24 pieces span the 24 musical keys (there are musically distinct 12 scale notes, and each may use major or minor tonality). The 12 distinct scale notes are:
Five of the notes have two alternate names, as is indicated above with equals sign. Thus, there are 17 possible names of scale notes, but only 12 musically distinct notes. When using one of these as the keynote for a musical key, we can further distinguish between major and minor tonalities. This gives 34 possible keys, of which 24 are musically distinct.
In naming his preludes, Mr. B used all the keys except the following 10, which were named instead by their alternate names:
Write a program that, given the name of a key, give an alternate name if it has one, or report the key name is unique.
![](https://i-blog.csdnimg.cn/blog_migrate/391c9d32a716958f9e8ef079e540b6ca.jpeg)
Five of the notes have two alternate names, as is indicated above with equals sign. Thus, there are 17 possible names of scale notes, but only 12 musically distinct notes. When using one of these as the keynote for a musical key, we can further distinguish between major and minor tonalities. This gives 34 possible keys, of which 24 are musically distinct.
In naming his preludes, Mr. B used all the keys except the following 10, which were named instead by their alternate names:
![](https://i-blog.csdnimg.cn/blog_migrate/bda406b9f7df9329e1cb70f322f65773.jpeg)
Write a program that, given the name of a key, give an alternate name if it has one, or report the key name is unique.
Input
Each test case is described by one line having the format "note tonality", where "note" is one of the 17 names for the scale notes given above, and "tonality" is either "major" or "minor" (quotes for clarify).
Output
For each case output the required answer, following the format of the sample.
Sample Input
Ab minor D# major G minor
Sample Output
Case 1: G# minor Case 2: Eb major Case 3: UNIQUE
The Famous Clock
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
都是大大大水题,唯一不水的就是题目是英文的。
第一个题目:
第一个12个种字符串,其中存在5种。这5中有两个表示方法。
输入两个字符串。(其实,两种情况字符串长度分别为2 和1)
第一种情况:第一个如果是5种中的一种,装换输出,第二个不变。
第二种情况:第一个是其他的7种,输出UNIQUE。
第二个题目:
一共就十二种情况。输入判断着十二种情况。
A Famous Music Composer
#include<iostream>
#include<map>
#include<cstring>
#include<string>
#include<cstdio>
using namespace std;
int main()
{
map <string,string>str;
str["A#"]="Bb"; str["Bb"]="A#";
str["C#"]="Db"; str["Db"]="C#";
str["D#"]="Eb"; str["Eb"]="D#";
str["F#"]="Gb"; str["Gb"]="F#";
str["G#"]="Ab"; str["Ab"]="G#";
int len,count=1;
char a[10],b[10];
while(~scanf("%s%s",a,b))
{
len=strlen(a);
if(len==1)
printf("Case %d: %s\n",count++,"UNIQUE");
else
{
printf("Case %d: ",count++);
cout<<str[a]<<" "<<b<<endl; //用map,输出不能用printf
}
}
return 0;
}
The Famous Clock
#include<stdio.h> #include<cstring> #include<iostream> #include<map> #include<string> using namespace std; int main() { int count=1; char a[5]; map<string,int>str; str["I"] =1; str["II"] =2; str["III"] =3; str["IV"] =4; str["V"] =5; str["VI"] =6; str["VII"] =7; str["VIII"]=8; str["IX"] =9; str["X"] =10; str["XI"] =11; str["XII"] =12; while(cin>>a) { printf("Case %d: ",count++); cout<<str[a]<<endl; } return 0; }