結果

問題 No.1905 PURE PHRASE
ユーザー ThetaTheta
提出日時 2022-10-11 18:58:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 257 ms / 2,000 ms
コード長 833 bytes
コンパイル時間 369 ms
コンパイル使用メモリ 10,952 KB
実行使用メモリ 52,964 KB
最終ジャッジ日時 2023-09-07 19:57:05
合計ジャッジ時間 13,322 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 248 ms
52,116 KB
testcase_01 AC 251 ms
52,456 KB
testcase_02 AC 245 ms
52,796 KB
testcase_03 AC 238 ms
52,736 KB
testcase_04 AC 237 ms
52,764 KB
testcase_05 AC 245 ms
52,896 KB
testcase_06 AC 246 ms
52,564 KB
testcase_07 AC 239 ms
52,576 KB
testcase_08 AC 240 ms
52,860 KB
testcase_09 AC 239 ms
52,672 KB
testcase_10 AC 239 ms
52,548 KB
testcase_11 AC 241 ms
52,448 KB
testcase_12 AC 241 ms
52,964 KB
testcase_13 AC 254 ms
52,596 KB
testcase_14 AC 236 ms
52,744 KB
testcase_15 AC 241 ms
52,496 KB
testcase_16 AC 244 ms
52,752 KB
testcase_17 AC 237 ms
52,540 KB
testcase_18 AC 235 ms
52,664 KB
testcase_19 AC 243 ms
52,420 KB
testcase_20 AC 244 ms
52,716 KB
testcase_21 AC 257 ms
52,688 KB
testcase_22 AC 243 ms
52,440 KB
testcase_23 AC 239 ms
52,572 KB
testcase_24 AC 245 ms
52,616 KB
testcase_25 AC 249 ms
52,608 KB
testcase_26 AC 247 ms
52,900 KB
testcase_27 AC 246 ms
52,700 KB
testcase_28 AC 245 ms
52,452 KB
testcase_29 AC 245 ms
52,316 KB
testcase_30 AC 252 ms
52,432 KB
testcase_31 AC 241 ms
52,392 KB
testcase_32 AC 241 ms
52,688 KB
testcase_33 AC 242 ms
52,548 KB
testcase_34 AC 243 ms
52,528 KB
testcase_35 AC 240 ms
52,560 KB
testcase_36 AC 245 ms
52,620 KB
testcase_37 AC 242 ms
52,712 KB
testcase_38 AC 245 ms
52,872 KB
testcase_39 AC 247 ms
52,392 KB
testcase_40 AC 253 ms
52,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from scipy.fft import fft
import numpy as np


heltz = {
    "C4": 261.6,
    "D4": 294.3,
    "E4": 327.0,
    "F4": 348.8,
    "G4": 392.4,
    "A4": 436.0,
    "B4": 490.5
}


def main():
    _ = input()
    A = list(map(int, input().split()))
    A_fft = fft(A)
    A_fft_abs = np.abs(A_fft)
    A_fft_freq = np.fft.fftfreq(44100, d=1/44100)
    main_frequency = A_fft_freq[np.where(A_fft_abs > np.max(A_fft_abs)/10)]
    sound_errors = {}
    for sound_name, freq in heltz.items():
        relative_frequency = main_frequency / freq
        relative_frequency_rounded = np.round(relative_frequency)
        sound_errors[sound_name] = np.linalg.norm(
            relative_frequency-relative_frequency_rounded)

    print(min(sound_errors, key=lambda sound_name: sound_errors[sound_name]))


if __name__ == "__main__":
    main()
0