結果

問題 No.1905 PURE PHRASE
ユーザー 👑 hitonanodehitonanode
提出日時 2022-02-06 15:06:19
言語 C++23(draft)
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 1,231 bytes
コンパイル時間 1,206 ms
コンパイル使用メモリ 88,436 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-04 19:39:43
合計ジャッジ時間 3,077 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,380 KB
testcase_01 AC 5 ms
4,380 KB
testcase_02 AC 5 ms
4,380 KB
testcase_03 AC 5 ms
4,380 KB
testcase_04 AC 6 ms
4,380 KB
testcase_05 AC 5 ms
4,376 KB
testcase_06 AC 6 ms
4,388 KB
testcase_07 AC 5 ms
4,376 KB
testcase_08 AC 5 ms
4,380 KB
testcase_09 AC 5 ms
4,380 KB
testcase_10 AC 6 ms
4,384 KB
testcase_11 AC 5 ms
4,380 KB
testcase_12 AC 5 ms
4,380 KB
testcase_13 AC 5 ms
4,384 KB
testcase_14 AC 5 ms
4,380 KB
testcase_15 AC 5 ms
4,376 KB
testcase_16 AC 5 ms
4,500 KB
testcase_17 AC 6 ms
4,380 KB
testcase_18 AC 6 ms
4,376 KB
testcase_19 AC 5 ms
4,376 KB
testcase_20 AC 5 ms
4,380 KB
testcase_21 AC 5 ms
4,380 KB
testcase_22 AC 5 ms
4,380 KB
testcase_23 AC 5 ms
4,380 KB
testcase_24 AC 5 ms
4,380 KB
testcase_25 AC 5 ms
4,380 KB
testcase_26 AC 5 ms
4,380 KB
testcase_27 AC 5 ms
4,380 KB
testcase_28 AC 5 ms
4,376 KB
testcase_29 AC 5 ms
4,380 KB
testcase_30 AC 5 ms
4,380 KB
testcase_31 AC 5 ms
4,376 KB
testcase_32 AC 5 ms
4,380 KB
testcase_33 AC 5 ms
4,376 KB
testcase_34 AC 6 ms
4,380 KB
testcase_35 AC 5 ms
4,384 KB
testcase_36 AC 5 ms
4,376 KB
testcase_37 AC 6 ms
4,380 KB
testcase_38 AC 5 ms
4,380 KB
testcase_39 AC 5 ms
4,376 KB
testcase_40 AC 5 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// 想定解1
// (A_i) と (A_{i + period}) の内積(自己相関)を見る
#include <iostream>
#include <vector>
using namespace std;

const vector<double> freqs{261.6, 294.3, 327.0, 348.8, 392.4, 436.0, 490.5};

int main() {
    cin.tie(nullptr), ios::sync_with_stdio(false);

    int N;
    cin >> N;
    vector<int> A(N);
    for (auto &x : A) cin >> x;

    long long bestscore = -1;
    int argbest = -1;
    for (int d = 0; d < freqs.size(); ++d) {
        long long score = 0;

        // freq[d] Hz -> 長さ N で freq[d] 周期 -> 一周期 period は N / freq[d] 要素分
        int period = N / freqs[d];

        for (int i = 0; i < N / 2; ++i) {
            // 周期が period くらいならば、
            // A[i] 自体と A[i] を period だけずらした A'[i] = A[i + period] は
            // ほぼ同じ形状になるはず
            // A と A' の内積を適当にとって、これが最大になるようなものが答え
            score += (long long)A[i] * A[i + period];
        }
        if (score > bestscore) {
            bestscore = score;
            argbest = d;
        }
    }
    cout << (char)('A' + (2 + argbest) % 7) << "4\n";
}
0