結果

問題 No.657 テトラナッチ数列 Easy
ユーザー cra77756176cra77756176
提出日時 2022-12-26 21:41:03
言語 Rust
(1.77.0)
結果
RE  
実行時間 -
コード長 809 bytes
コンパイル時間 15,414 ms
コンパイル使用メモリ 384,000 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-01 06:09:14
合計ジャッジ時間 13,285 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,816 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 4 ms
6,944 KB
testcase_05 AC 13 ms
6,944 KB
testcase_06 RE -
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 5 ms
6,940 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 16 ms
6,940 KB
testcase_13 AC 19 ms
6,944 KB
testcase_14 AC 19 ms
6,940 KB
testcase_15 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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.sort_unstable();
    xx_sorted.dedup();
    let xx_sorted = xx_sorted;

    let n_max = *xx.iter().max().unwrap();

    let mut values: HashMap<usize, i32> = [(1, 0), (2, 0), (3, 0), (4, 1)].into_iter().collect();
    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]);
    }
}
0