编程介的小学生 2017-09-03 11:35 采纳率: 20.5%
浏览 898
已采纳

Major Scales

In music, the range of audible frequencies is divided into octaves, where each octave spans frequencies within factor of 2 of one another. For example, the note called middle C corresponds to an audio frequency of 263 Hz. The octave below middle C spans the frequency range from 131.5 Hz to 263 Hz while the octave above middle C spans the range from 263 Hz to 526 Hz.

An octave contains 13 chromatic notes whose frequencies differ by a common ratio. The separation between two adjacent chromatic notes is called a half-step or semi-tone. Note that there are 12 semi-tones in an octave and therefore the frequency ratio represented by a semi-tone is 1.0593 (since 1.0593^12 = 2). A tone is two semi-tones.
While it might be convenient to use frequencies to describe musical notes, historical tradition demands that we name the notes of the chromatic scale, in order: C, C#, D, D#, E, F, F#, G, G#, A, A#, B, C, and so on, repeating the same names for each new octave.

Western music rarely uses all the notes in the chromatic scale. Instead, 8 of the 13 chromatic notes are commonly used a composition. The most common such set of 8 notes is the major scale. The 8 notes of a major scale, in order, are separated by: tone, tone, semi-tone, tone, tone, tone, semi-tone. A major scale can begin with any of the chromatic notes; this note defines the key of the scale. Coincidentally, in the key of C, the major scale consists of the notes: C, D, E, F, G, A, B, C. On the other hand, in the key of F, the major scale is: F, G, A, A#, C, D, E, F.

There are other scales, notably the minor scale, and music composed in a particular scale sometimes uses notes that are not within the scale, caled accidentals. We shall concern ourselves only with music composed in a major scale with no accidentals.

Your job is to read a sequence of notes and to identify all the keys that the music might have been composed in. Your program need not have any musical ear: report a particular key if and only if all the notes come from the major scale in that key.

Input

Input contains several test cases. Each test case consists of a single line of input, containing a sequence of chromatic notes separated by white space. No input line exceeds 1000 characters. The last line of input contains the word "END".

Output

For each test case, output a line giving the possible keys, in the order given above.

Sample Input

C C D F E G A A F G B
A B C D E F G C#
C C D F E G A A F G
C C C C C
END

Sample Output

C

C F
C C# D# F G G# A#

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-09-17 14:41
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体