[요약] | 를 구분자로 하여
예를 들어
CD|EC|CD|EC|EF|G|EF|G|GAGF|EC|GAGF|EC|CG|C|CG|C첫 문자는 C, E, C, E, E, G, E, G, G, E, G, E, C, C, C, C.
이 중 10 개 (C, C, G, G, G, G, C, C, C, C)가 C 메이저 나머지 6 개 (E, E, E, E, E, E)가 A 마이너이므로 C 메이저를 출력하면 됨.
입력이
EFDCDF|GDA이면 개수가 같아서 마지막 문자 A 로서 판단. 마지막 문자는 6 문자 중 하나가 된다는 것은 보장 됨.
Still, out of the 12 tones of an octave {A, A#, B, C, C#, D, D#, E, F, F#, G, G#} used in modern music1, A-minor and C-major scales do use the tones with shortest names: A-minor is defined as an ordered septuple (A, B, C, D, E, F, G), and C-major as (C, D, E, F, G, A, B).
Notice that the sets of tones of these two scales are equal. What's the difference? The catch is that not only the set of tones, but also their usage, determines a scale. Specifically, the tonic (the first tone of a scale), subdominant (the fourth tone) and dominant (the fifth tone) are the primary candidates for accented tones in a composition. In A-minor, these are A, D, and E, and in C-major, they are C, F, and G. We will name these tones main tones.
Aren't the scales still equivalent save for translation? They are not: for example, the third tone of Aminor (C) is three half-tones higher than the tonic (A), while the third tone of C-major (E) is four halftones higher than the tonic (C). The difference, therefore, lies in the intervals. This makes minor scales “sad” and major scales “happy”.
Write a program to decide if a composition is more likely written in A-minor or C-major by counting whether there are more main tones of A-minor or of C-major among the accented tones (the first tones in each measure). If there is an equal number of main tones, determine the scale based on the last tone (which is guaranteed to be either A for A-minor or C for C-major in any such test case). For example, examine the well-known melody “Frere Jacques” :
CD|EC|CD|EC|EF|G|EF|G|GAGF|EC|GAGF|EC|CG|C|CG|CThe character “|” separates measures, so the accented tones are, in order: C, E, C, E, E, G, E, G, G, E, G, E, C, C, C, C. Ten of them (C, C, G, G, G, G, C, C, C, C) are main tones of C-major, while six (E, E, E, E, E, E) are main tones of A-minor. Therefore, our best estimate is that the song was written in C-major.
input AEB|C output C-dur input CD|EC|CD|EC|EF|G|EF|G|GAGF|EC|GAGF|EC|CG|C|CG|C output C-dur
출처:coci/2012-2013/contest5 1번/6