結果

問題 No.657 テトラナッチ数列 Easy
ユーザー pekempeypekempey
提出日時 2018-03-02 22:25:43
言語 Rust
(1.77.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 712 bytes
コンパイル時間 3,139 ms
コンパイル使用メモリ 143,556 KB
実行使用メモリ 5,840 KB
最終ジャッジ日時 2023-09-03 22:43:10
合計ジャッジ時間 4,247 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
5,820 KB
testcase_01 AC 7 ms
5,816 KB
testcase_02 AC 6 ms
5,820 KB
testcase_03 AC 6 ms
5,836 KB
testcase_04 AC 7 ms
5,840 KB
testcase_05 AC 20 ms
5,740 KB
testcase_06 AC 6 ms
5,832 KB
testcase_07 AC 7 ms
5,828 KB
testcase_08 AC 7 ms
5,840 KB
testcase_09 AC 23 ms
5,820 KB
testcase_10 AC 23 ms
5,812 KB
testcase_11 AC 24 ms
5,840 KB
testcase_12 AC 25 ms
5,816 KB
testcase_13 AC 26 ms
5,812 KB
testcase_14 AC 25 ms
5,792 KB
testcase_15 AC 26 ms
5,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
  let mut a: Vec<i32> = vec![0; 1000001];
  a[4] = 1;

  for i in 5..1000001 {
    a[i] = (a[i - 1] + a[i - 2] + a[i - 3] + a[i - 4]) % 17;
  }

  let q: usize = input();
  for _ in 0..q {
    let n: usize = input();
    println!("{}", a[n]);
  }
}

fn input<T: std::str::FromStr>() -> T {
  use std::io::Read;
  let stdin = std::io::stdin();
  let stdin = stdin.bytes();
  let token = stdin
    .skip_while(|x| (*x.as_ref().unwrap() as char).is_whitespace())
    .take_while(|x| !(*x.as_ref().unwrap() as char).is_whitespace())
    .map(|x| x.unwrap())
    .collect();
  let token = String::from_utf8(token).unwrap();
  match token.parse() {
    Ok(x) => x,
    Err(_) => panic!("{}", token),
  }
}
0