A Famous Music Composer
Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 460Accepted Submission(s): 271
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.
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
A#=Bb 表示这2个串 可以互换
输入2个串 把第一个串换掉后输出 第二个直接输出 如果第一个换不掉 输出UNIQUE
Source
#include<stdio.h>
#include<string.h>
struct haha
{
char str1[10];
char str2[10];
}a[20];
int main()
{
int cas=0,i;
char s1[100],s2[100];
strcpy(a[1].str1,"A#");
strcpy(a[1].str2,"Bb");
strcpy(a[2].str1,"Bb");
strcpy(a[2].str2,"A#");
strcpy(a[3].str1,"C#");
strcpy(a[3].str2,"Db");
strcpy(a[4].str1,"Db");
strcpy(a[4].str2,"C#");
strcpy(a[5].str1,"D#");
strcpy(a[5].str2,"Eb");
strcpy(a[6].str1,"Eb");
strcpy(a[6].str2,"D#");
strcpy(a[7].str1,"F#");
strcpy(a[7].str2,"Gb");
strcpy(a[8].str1,"Gb");
strcpy(a[8].str2,"F#");
strcpy(a[9].str1,"G#");
strcpy(a[9].str2,"Ab");
strcpy(a[10].str1,"Ab");
strcpy(a[10].str2,"G#");
while(scanf("%s %s",s1,s2)!=EOF)
{
for(i=1;i<=10;i++)
{
if(strcmp(s1,a[i].str1)==0) break;
}
if(i>10) printf("Case %d: UNIQUE\n",++cas);
else printf("Case %d: %s %s\n",++cas,a[i].str2,s2);
}
return 0;
}
分享到:
相关推荐
HDU的1250,主要是利用高精度加法,但是代码有点繁琐,效率不是很高
杭电ACMhdu1163
HDU1059的代码
hdu1001解题报告
hdu 1574 passed sorce
HDU的一题........HDU DP动态规
hdu acm 教案 搜索入门 hdu acm 教案 搜索入门
hdu2101AC代码
搜索 dfs 解题代码 hdu1241
hdu 5007 Post Robot 字符串枚举。 暴力一下就可以了。
现在,给你两个正的小数A和B,你的任务是代表大明计算出A+B的值。 Input 本题目包含多组测试数据,请处理到文件结束。 每一组测试数据在一行里面包含两个长度不大于400的正小数A和B。 Output 请在一行里面...
hdu_2102_passed_sorce
hdu acm 教案 动态规划(1) hdu acm 教案 动态规划(1)
ACM HDU题目分类,我自己总结的大概只有十来个吧
hdu 1166线段树代码
HDU最全ac代码
自己做的HDU ACM已经AC的题目
hdu动态规划算法集锦
hdu题目分类