ZOJ Problem Set - 1274
The ``names" of the notes on a standard 88-key piano keyboard start with A (the lowest note on the keyboard) and then proceed sequentially with A# (A-sharp), B, C, C#, D, D#, E, F, F#, G, and finally G#. After the first 12 notes are named, the pattern repeats, proceeding through the last key, which is named C. Some notes have other common names. A# may also be called Bb (B-flat), C# may be called Db, D# may be called Eb, F# may be called Gb, and G# may be called Ab. (There are still other names, like Cx, but we won't worry about those here!)
Most music includes chords, or groups of notes played at the same time. Many of these chords are given standard names. For example, the notes C, E, and G sounded together are called a C Major chord. While the particular C, E and G in the chord are frequently close together on the keyboard, for our purposes here, any C, E, and G played at the same time will constitute a C Major chord. It is the spacing between the notes on the keyboard that distinguishes a Major chord from others. As you can see, there are exactly three notes skipped between the C and the E (namely C#, D and D#), and then only two skipped between the E and the G (namely F and F#). If we start with a different note, say F#, we can easily tell that the notes in an F# Major chord are F#, A#, and C# (skipping G, G#, and A between F# and A#, and skipping B and C between A# and C#).
Another frequently encountered chord is the Minor chord. C Minor, for example, is played by sounding C, D#, and G. As you can see, C# and D are skipped between C and D#, and E, F and F# are skipped between D# and G. You should now be able to tell that the notes in an F# Minor chord are F#, A, and C#.
In this problem you will be presented with a sequence of lines, each containing the names of three notes. You are to identify if these three notes, taken together, form a Major or Minor chord. If they do, you will display the name of the chord. If they don't you'll also report that fact. Remember that the notes need not appear in the usual sequence. Case will be ignored in the input, and the symbol b will be indicated by the letter b. A blank or blanks will appear between the notes on each line, and may also precede the first note on the line or follow the third note on the line.
The output is to be in the same style as shown in the examples below; do not use b to name chords: use only # when necessary.
C E G
C E G is a C Major chord.
Source: North Central North America 1996