結果
問題 | No.657 テトラナッチ数列 Easy |
ユーザー |
![]() |
提出日時 | 2022-12-26 21:45:11 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 21 ms / 2,000 ms |
コード長 | 835 bytes |
コンパイル時間 | 12,832 ms |
コンパイル使用メモリ | 394,500 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-21 07:55:28 |
合計ジャッジ時間 | 13,967 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 |
ソースコード
use std::collections::HashMap;fn main() {let mut xx = String::new();std::io::Read::read_to_string(&mut std::io::stdin(), &mut xx).ok();let xx: Vec<usize> = xx.split_whitespace().skip(1).flat_map(str::parse).collect();let mut xx_sorted = xx.clone();xx_sorted.retain(|&n| n > 4);xx_sorted.sort_unstable();xx_sorted.dedup();let xx_sorted = xx_sorted;let n_max = *xx.iter().max().unwrap();let mut values = HashMap::new();values.extend([(1, 0), (2, 0), (3, 0), (4, 1)]);let mut t = (0, 0, 0, 1);let mut i_xx = 0;for i in 5..=n_max {t = (t.1, t.2, t.3, (t.0 + t.1 + t.2 + t.3) % 17);if i == xx_sorted[i_xx] {values.insert(i, t.3);i_xx += 1;}}for &n in &xx {println!("{}", values[&n]);}}