BRHMUSIC - Musical Frequencies

Butch is learning about the frequencies of musical notes, and he wants you to help him check whether he's calculated them correctly.

A formula you can use to calculate frequences is

f = 440 * 2N/12

Where N is the number of half-steps away from A4. (Note that if N is negative, that means it's half-steps to the left.)

In case you aren't familiar with a piano, here's a sample:

http://www.balaams-ass.com/octave01.jpg

A half-step is the next note over; either a sharp (black note--denoted by the # symbol), if that note has one, or just the next note.

Butch would like to give you a note, and have you calculate that note's frequency. Butch will only input sharps or regular notes (so no flats, for those musically talented competitors). The lowest note will be C0, and the highest will be D#8.

For an extra challenge: Use a function to generically find the distance between any two notes--not just A4. This may be used to break ties.

Input

Line 1: String representing the note

Output

Line 1: The frequency, TO 6 DECIMAL PLACES.

Example

Input:
C#5

Output: 554.365261
Butch is learning about the frequencies of musical notes, and he wants you to help him check whether he's calculated them correctly.

A formula you can use to calculate frequences is

f = 440 * (2)^(N/12)

Where N is the number of half-steps away from A4. (Note that if N is negative, that means it's half-steps to the left.)

In case you aren't familiar with a piano, here's a sample:

http://www.balaams-ass.com/octave01.jpg

A half-step is the next note over; either a sharp (black note--denoted by the # symbol), if that note has one, or just the next note.

Butch would like to give you a note, and have you calculate that note's frequency. Butch will only input sharps or regular notes (so no flats, for those musically talented competitors). The lowest note will be C0, and the highest will be D#8.

For an extra challenge: Use a function to generically find the distance between any two notes--not just A4.

Added by:Damon Doucet
Date:2009-12-05
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 NODEJS OBJC PERL6 SQLITE VB.NET

© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.