
ZOJ Problem Set  3401
The guitar is a plucked string instrument, played either with fingers or a pick. The guitar consists of a body with a rigid neck to which the strings, generally six in number. Frets are metal strips (usually nickel alloy or stainless steel) embedded along the fretboard and located at exact points that divide the scale length in accordance with a specific mathematical formula. Pressing a string against a fret determines the strings' vibrating length and therefore its resultant pitch. The pitch of each consecutive fret is defined at a halfstep interval on the chromatic scale. Scales are typically listed from low to high. Most scales are octaverepeating, meaning their pattern of notes is the same in every octave. An octaverepeating scale can be represented as a circular arrangement of pitch classes, ordered by increasing pitch class. For instance, the increasing C major scale is, CDEFGAB[C], with the bracket indicating that the last note is an octave higher than the first note. In scientific pitch notation, An octaverepeating scale CDEFGAB[C] is written as CiDiEiGiAiBi[Ci+1], i.e., if i = 4, it's C4D4E4F4G4A4B4[C5]. The interval between two successive pitch is described in the pictures below, where HS = halfstep and WS = wholestep: Now, let's use a mathematical form to describe what was described above. In this problem, we define:
You should output the pitch you play using scientific pitch notation. See "Output" for more details. InputThere are multiple cases. In each case, there is one of two operations described above in a single line. A single number 0 in a single line indicates the end of the case. There is a blank line between two cases. OutputFor each case, output the pitch you play using scientific pitch notation. If you can't use C D E F G A B to denote the pitch, add a symbol "#" after it, like C4#, D5# and etc., but E3# is forbidden because E3# = F3. Output every pitch in a single line. Output a blank line between two cases. All the cases contain at sleast two lines. Sample Input6 5 4 3 2 1 0 0 1 0 2 3 0 6 5 4 3 2 1 1 1 1 1 1 1 1 2 3 4 5 6 0 Sample OutputE3 A3 D4 G4 B4 E5 E3 C4 E4 G4 C5 E5 F5 C5 G4# D4# A3# F3 Author: YU, Xiaoyao Contest: ZOJ Monthly, September 2010 