結果
問題 | No.658 テトラナッチ数列 Hard |
ユーザー |
|
提出日時 | 2018-03-02 22:34:38 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 29 ms / 2,000 ms |
コード長 | 734 bytes |
コンパイル時間 | 17,266 ms |
コンパイル使用メモリ | 390,148 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-13 03:56:53 |
合計ジャッジ時間 | 14,014 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 |
ソースコード
fn main() { let mut a: Vec<i32> = vec![0; 1000000]; a[3] = 1; for i in 4..1000000 { 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 = input::<i64>() - 1; println!("{}", a[(n % 4912) as usize]); } } 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), } }