Program time limit: 1 second
Program memory limit: 128 MB
In music, two pitches are an octave apart if they have a frequency ratio of $2:1$. For example, The interval between a note at 440 hertz and another note at 880 hertz forms an octave.
In Western music (with the equal temperament tuning system), an octave is divided into $12$ pitches (excluding the pitch exactly one octave apart), with each note being $2^{\frac{1}{12}}$ higher in frequency than the previous. For example, if a note has a frequency of $440$ hertz, the next note up would have a frequency of $440 \times 2^{\frac{1}{12}} \approx 466.163762$ hertz, and the next note following that would have a frequency of $446.163762 \times 2^{\frac{1}{12}} \approx 493.883301$ hertz.
Notes are tuned relative to a reference pitch of 440 hertz, named A
. Going upwards in frequency, the notes are named A
, A#
, B
, C
, C#
, D
, D#
, E
, F
, F#
, G
, and G#
, then it wraps back around to being A
.
Given a frequency in hertz, what is the name of the note that is the closest to that frequency?
The first and only line of input contains $1$ floating-point number (rounded to $6$ decimal places), $h$, which is the provided note's frequency in hertz.
You should read from standard input.
In Python, you could use the line h = float(input())
.
In C++, you could use the line double f; cin >> f;
.
For all test cases:
Output a single line, containing the name of the note that is closest to the provided frequency.
The answer should fall within one of the twelve options in A
, A#
, B
, C
, C#
, D
, D#
, E
, F
, F#
, G
, and G#
. It is guaranteed that there is only one solution for each test case.
You should write to standard output.
In Python, you could use the line print(answer)
.
In C++, you could use the line cout << answer;
.
440.000001
A
This note is between an A
($440.000000$ hertz) and an A#
($466.163762$ hertz). Since it is closer to A
, the answer is A
.
19899.999999
D#
This note is between a D
($18794.545146$ hertz) and a D#
($19912.126958$ hertz). Since it is closer to D#
, the answer is D#
.
47.134732
F#
This note is between an F#
($46.249303$ hertz) and an G
($48.999429$ hertz). Since it is closer to F#
, the answer is F#
.
Your program will be run on the 2 sample cases and 30 secret cases one after another. You must pass all testcases in order to score points.
Recall that your final score on the task is the score of your highest scoring submission.
You haven't submitted to this task.