結果
| 問題 |
No.1905 PURE PHRASE
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-10 18:08:47 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 932 bytes |
| コンパイル時間 | 12,668 ms |
| コンパイル使用メモリ | 386,984 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-24 12:08:25 |
| 合計ジャッジ時間 | 13,714 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
const C4: f64 = 261.6;
const D4: f64 = 294.3;
const E4: f64 = 327.0;
const F4: f64 = 348.8;
const G4: f64 = 392.4;
const A4: f64 = 436.0;
const B4: f64 = 490.5;
fn main() {
let mut n = String::new();
std::io::stdin().read_line(&mut n).ok();
let n: usize = n.trim().parse().unwrap();
let mut a = String::new();
std::io::stdin().read_line(&mut a).ok();
let a: Vec<isize> = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
let mut sounds = vec![0isize; 7];
let hz = vec![C4, D4, E4, F4, G4, A4, B4];
let words = vec!["C4", "D4", "E4", "F4", "G4", "A4", "B4"];
for j in 0..hz.len() {
let period = (n as f64 / hz[j]).floor() as usize;
for i in 0..n/2 {
sounds[j] += (a[i] - a[i + period]).abs();
}
}
eprintln!("{:?}", sounds);
let idx = sounds.iter().enumerate().min_by_key(|(_, &v)| v).unwrap().0;
println!("{}", words[idx]);
}