結果
問題 | No.657 テトラナッチ数列 Easy |
ユーザー |
|
提出日時 | 2018-03-02 22:25:43 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 25 ms / 2,000 ms |
コード長 | 712 bytes |
コンパイル時間 | 13,626 ms |
コンパイル使用メモリ | 392,564 KB |
実行使用メモリ | 5,888 KB |
最終ジャッジ日時 | 2024-06-13 03:20:50 |
合計ジャッジ時間 | 14,886 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 |
ソースコード
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), } }