結果

問題 No.1905 PURE PHRASE
ユーザー tktk_snsntktk_snsn
提出日時 2022-04-15 22:37:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 150 ms / 2,000 ms
コード長 540 bytes
コンパイル時間 107 ms
コンパイル使用メモリ 10,960 KB
実行使用メモリ 33,480 KB
最終ジャッジ日時 2023-08-26 08:20:04
合計ジャッジ時間 7,841 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 146 ms
32,780 KB
testcase_01 AC 149 ms
32,764 KB
testcase_02 AC 148 ms
32,860 KB
testcase_03 AC 150 ms
32,884 KB
testcase_04 AC 149 ms
33,364 KB
testcase_05 AC 145 ms
33,320 KB
testcase_06 AC 146 ms
33,292 KB
testcase_07 AC 145 ms
33,280 KB
testcase_08 AC 142 ms
32,724 KB
testcase_09 AC 147 ms
33,360 KB
testcase_10 AC 144 ms
33,244 KB
testcase_11 AC 146 ms
32,736 KB
testcase_12 AC 145 ms
33,292 KB
testcase_13 AC 144 ms
33,372 KB
testcase_14 AC 144 ms
32,908 KB
testcase_15 AC 144 ms
32,948 KB
testcase_16 AC 142 ms
32,688 KB
testcase_17 AC 147 ms
32,696 KB
testcase_18 AC 144 ms
33,360 KB
testcase_19 AC 143 ms
32,840 KB
testcase_20 AC 142 ms
33,480 KB
testcase_21 AC 144 ms
32,956 KB
testcase_22 AC 142 ms
33,056 KB
testcase_23 AC 145 ms
32,880 KB
testcase_24 AC 147 ms
33,220 KB
testcase_25 AC 141 ms
32,756 KB
testcase_26 AC 143 ms
32,676 KB
testcase_27 AC 149 ms
33,072 KB
testcase_28 AC 148 ms
32,940 KB
testcase_29 AC 149 ms
32,872 KB
testcase_30 AC 149 ms
32,888 KB
testcase_31 AC 146 ms
32,876 KB
testcase_32 AC 147 ms
33,416 KB
testcase_33 AC 144 ms
32,856 KB
testcase_34 AC 143 ms
33,424 KB
testcase_35 AC 140 ms
32,788 KB
testcase_36 AC 142 ms
33,404 KB
testcase_37 AC 142 ms
32,832 KB
testcase_38 AC 142 ms
33,248 KB
testcase_39 AC 143 ms
32,868 KB
testcase_40 AC 144 ms
32,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
from numpy import fft

code = ["C4", "D4", "E4", "F4", "G4", "A4", "B4", ]
freq = [261.6, 294.3, 327.0, 348.8, 392.4, 436.0, 490.5, ]


def main(N, A):
    f = fft.rfftfreq(N, 1/N)
    C = fft.rfft(A, N)

    fpeak = f[np.argsort(np.abs(C))[-20:]]

    dif = [np.abs(fpeak - freq[i]).min() for i in range(7)]
    ans = -1
    p = 1e12
    for i, d in enumerate(dif):
        if p > d:
            ans = i
            p = d
    print(code[ans])


N = int(input())
A = np.array(input().split(), dtype=np.float64)
main(N, A)
0