// 想定別解 // exp(2 pi i f t) と内積をとって絶対値最大のものを出力する #include #include #include #include using namespace std; const vector freqs{261.6, 294.3, 327.0, 348.8, 392.4, 436.0, 490.5}; const vector names{"C4", "D4", "E4", "F4", "G4", "A4", "B4"}; int main() { cin.tie(nullptr), ios::sync_with_stdio(false); int N; cin >> N; vector A(N); for (auto &x : A) cin >> x; const double PI = acos(-1); double high = -1; int arghi = -1; for (int d = 0; d < int(freqs.size()); ++d) { complex v = 0; for (int frame = 0; frame < N; ++frame) { double hanning = 0.5 - 0.5 * cos(PI * 2 * frame / N); v += exp(complex(0.0, PI * 2 * frame / N * freqs[d])) * A[frame] * hanning; } if (high < abs(v)) { high = abs(v); arghi = d; } } cout << names.at(arghi) << '\n'; }