杭电OJ第4245题 A Famous Music Composer
2015-04-15 22:11
435 查看
杭电OJ第4245题,A Famous Music Composer(题目链接)。
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
Source
Fudan Local Programming Contest 2012
解题思路:逐一判断,有别名的输出别名;没有别名的输出UNIQUE
C语言源代码如下:
A Famous Music Composer
Problem DescriptionMr. 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:
A | A#=Bb | B | C | C#=Db | D | D#=Eb | E | F | F#=Gb | G | G#=Ab |
In naming his preludes, Mr. B used all the keys except the following 10, which were named instead by their alternate names:
Ab minor | A# major | A# minor | C# major | Db minor |
D# major | D# minor | Gb major | Gb minor | G# minor |
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
Source
Fudan Local Programming Contest 2012
解题思路:逐一判断,有别名的输出别名;没有别名的输出UNIQUE
C语言源代码如下:
#include <stdio.h> #include <stdlib.h> #include <assert.h> #include <stdbool.h> int main (void) { int test_case = 0; char note[1000]; while ( gets( note ) != NULL ) { test_case ++; if ( note[0] == 'A' && note[1] == ' ' ) printf( "Case %d: UNIQUE\n", test_case ); else if ( note[0] == 'A' && note[1] == '#' ) { note[0] = 'B'; note[1] = 'b'; printf( "Case %d: %s\n", test_case, note ); } else if ( note[0] == 'B' && note[1] == 'b' ) { note[0] = 'A'; note[1] = '#'; printf( "Case %d: %s\n", test_case, note ); } else if ( note[0] == 'B' && note[1] == ' ' ) printf( "Case %d: UNIQUE\n", test_case ); else if ( note[0] == 'C' && note[1] == ' ' ) printf( "Case %d: UNIQUE\n", test_case ); else if ( note[0] == 'C' && note[1] == '#' ) { note[0] = 'D'; note[1] = 'b'; printf( "Case %d: %s\n", test_case, note ); } else if ( note[0] == 'D' && note[1] == 'b' ) { note[0] = 'C'; note[1] = '#'; printf( "Case %d: %s\n", test_case, note ); } else if ( note[0] == 'D' && note[1] == ' ' ) printf( "Case %d: UNIQUE\n", test_case ); else if ( note[0] == 'D' && note[1] == '#' ) { note[0] = 'E'; note[1] = 'b'; printf( "Case %d: %s\n", test_case, note ); } else if ( note[0] == 'E' && note[1] == 'b' ) { note[0] = 'D'; note[1] = '#'; printf( "Case %d: %s\n", test_case, note ); } else if ( note[0] == 'E' && note[1] == ' ' ) printf( "Case %d: UNIQUE\n", test_case ); else if ( note[0] == 'F' && note[1] == ' ' ) printf( "Case %d: UNIQUE\n", test_case ); else if ( note[0] == 'F' && note[1] == '#' ) { note[0] = 'G'; note[1] = 'b'; printf( "Case %d: %s\n", test_case, note ); } else if ( note[0] == 'G' && note[1] == 'b' ) { note[0] = 'F'; note[1] = '#'; printf( "Case %d: %s\n", test_case, note ); } else if ( note[0] == 'G' && note[1] == ' ' ) printf( "Case %d: UNIQUE\n", test_case ); else if ( note[0] == 'G' && note[1] == '#' ) { note[0] = 'A'; note[1] = 'b'; printf( "Case %d: %s\n", test_case, note ); } else if ( note[0] == 'A' && note[1] == 'b' ) { note[0] = 'G'; note[1] = '#'; printf( "Case %d: %s\n", test_case, note ); } else assert(false); } return EXIT_SUCCESS; }
相关文章推荐
- 杭电OJ第4245题 A Famous Music Composer
- 南阳oj 题目25 A Famous Music Composer
- A Famous Music Composer(南阳oj25)(一道无聊的英文题)
- 南阳oj 25 A Famous Music Composer (水题,字符串替换问题)
- 杭电-A Famous Music Composer
- A Famous Music Composer
- 25 A Famous Music Composer
- hdu 4245 A Famous Music Composer--map
- A Famous Music Composer
- 07-语言入门-07-A Famous Music Composer
- NY25 A Famous Music Composer
- 南阳题目25-A Famous Music Composer
- HDU4245:A Famous Music Composer
- A famous music composer
- 杭电OJ第4252题 A Famous City
- A Famous Music Composer(map)
- NYOJ25 A Famous Music Composer
- NYOJ - A Famous Music Composer
- A Famous Music Composer
- nyoj 25 A Famous Music Composer