Logo
(追記) (追記ここまで)

31043번 - Minor Setback 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 1024 MB23151361.905%

문제

You are developing a smartphone app that converts audio recorded from an instrument into sheet music. You already have the code to record the audio and convert it into sequence of frequency values. What is left is to translate those frequencies into pitch names more easily recognizable to musicians.

Some Music Theory

Musical pitches are described by frequencies using a logarithmic scale. The frequency 440ドル\ \textrm{Hz}$ corresponds to the pitch named $\textrm{A}$. Multiplying a pitch’s frequency by $\sqrt [12]{2}$ produces the next higher pitch. Table 1 lists pitches used in Western music and their frequencies.

Table 1: Frequencies and corresponding pitch names of various notes.

frequency (Hz)

pitch name

frequency (Hz)

pitch name

440ドル$

$\textrm{A}$

440ドル \cdot 2^{6/12} \approx 622.25$

$\textrm{D}^{\sharp },ドル $\textrm{E}^{\flat }$

440ドル \cdot 2^{1/12} \approx 466.16$

$\textrm{A}^{\sharp },ドル $\textrm{B}^{\flat }$

440ドル \cdot 2^{7/12} \approx 659.26$

$\textrm{E}$

440ドル \cdot 2^{2/12} \approx 493.88$

$\textrm{B}$

440ドル \cdot 2^{8/12} \approx 698.46$

$\textrm{F}$

440ドル \cdot 2^{3/12} \approx 523.25$

$\textrm{C}$

440ドル \cdot 2^{9/12} \approx 739.99$

$\textrm{F}^{\sharp },ドル $\textrm{G}^{\flat }$

440ドル \cdot 2^{4/12} \approx 554.37$

$\textrm{C}^{\sharp },ドル $\textrm{D}^{\flat }$

440ドル \cdot 2^{10/12} \approx 783.99$

$\textrm{G}$

440ドル \cdot 2^{5/12} \approx 587.33$

$\textrm{D}$

440ドル \cdot 2^{11/12} \approx 830.61$

$\textrm{G}^{\sharp },ドル $\textrm{A}^{\flat }$

880ドル$

$\textrm{A}$

Doubling any pitch’s frequency yields the same pitch, but one octave higher (note that both 440ドル$ and 880ドル\ \textrm{Hz}$ correspond to pitch $\textrm{A}$). This rule generalizes: multiplying 554ドル.37\ \textrm{Hz}$ by a power of two yields another $\textrm{C}^{\sharp }$. Some pitches have multiple names, as shown in the table.

Your Task

You have a song, represented as a sequence of frequencies. Songs in a musical key typically contain only a subset of the possible pitches. Assume that the given song is in one of the common keys listed in Table 2. First, determine what key the song is in. Then, translate the song into a sequence of pitch names.

Table 2: A few musical keys and the pitches they use.

key name

allowed pitches

key name

allowed pitches

$\textrm{G}$ major

$\textrm{G},ドル $\textrm{A},ドル $\textrm{B},ドル $\textrm{C},ドル $\textrm{D},ドル $\textrm{E},ドル and $\textrm{F}^{\sharp }$

$\textrm{F}^{\sharp }$ minor

$\textrm{F}^{\sharp },ドル $\textrm{G}^{\sharp },ドル $\textrm{A},ドル $\textrm{B},ドル $\textrm{C}^{\sharp },ドル $\textrm{D},ドル and $\textrm{E}$

$\textrm{C}$ major

$\textrm{C},ドル $\textrm{D},ドル $\textrm{E},ドル $\textrm{F},ドル $\textrm{G},ドル $\textrm{A},ドル and $\textrm{B}$

$\textrm{G}$ minor

$\textrm{G},ドル $\textrm{A},ドル $\textrm{B}^{\flat },ドル $\textrm{C},ドル $\textrm{D},ドル $\textrm{E}^{\flat },ドル and $\textrm{F}$

$\textrm{E}^{\flat }$ major

$\textrm{E}^{\flat },ドル $\textrm{F},ドル $\textrm{G},ドル $\textrm{A}^{\flat },ドル $\textrm{B}^{\flat },ドル $\textrm{C},ドル and $\textrm{D}$

입력

The first line of input contains a single integer 1ドル \leq N \leq 100,円 000,ドル the number of frequencies in the song. The next $N$ lines each contain a real number 20ドル \le f \le 4,円 000,ドル representing one pitch frequency, with at most 8ドル$ digits after the decimal point. You may assume that the song was played using an instrument that is in tune, so that each frequency represents a valid pitch: each frequency approximates 440ドル\cdot 2^{a/12}$ for some integer $a$ with absolute error at most 10ドル^{-4}$.

출력

On the first line, output the name of the key that the song was played in: G major, F# minor, etc. See below for instructions for how to format pitch names. If the song does not fit any of the keys in Table 2, or if multiple possible keys could fit the song, print cannot determine key.

If the key could not be determined, print no further output. Otherwise, print $N$ lines, each containing one pitch name (in the order of the input sequence). Each pitch name should be a letter A through G followed optionally by a second character, either # or b, indicating a sharp or flat. Note that although pitches can have multiple names, only one of these names is listed in the allowed-pitches table for any given key, and this is the name you should use. For example, print C#, and not Db, when writing pitches for the key $\textrm{F}^{\sharp }$ minor.

제한

예제 입력 1

7
783.9908720
783.9908720
587.3295358
587.3295358
659.2551138
659.2551138
587.3295358

예제 출력 1

cannot determine key

예제 입력 2

5
523.2511306
391.9954360
440.0
329.6275569
369.9944227

예제 출력 2

G major
C
G
A
E
F#

힌트

출처

ICPC > Regionals > North America > South Central USA Regional > 2018 ICPC South Central USA Regional Programming Contest B번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /