結果
問題 |
No.533 Mysterious Stairs
|
ユーザー |
|
提出日時 | 2022-11-27 13:24:40 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 104 ms / 5,000 ms |
コード長 | 630 bytes |
コンパイル時間 | 13,841 ms |
コンパイル使用メモリ | 383,964 KB |
実行使用メモリ | 72,264 KB |
最終ジャッジ日時 | 2024-10-04 01:12:34 |
合計ジャッジ時間 | 14,653 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
ソースコード
const MOD: usize = 1e9 as usize + 7; fn main() { let mut n = String::new(); std::io::stdin().read_line(&mut n).ok(); let n: usize = n.trim().parse().unwrap(); let mut dp = vec![vec![0usize; 4]; n+1]; dp[0][0] = 1; for i in 0..n { for from in 0..4 { if dp[i][from] == 0 { continue; } for to in 1..4 { if from == to { continue; } if i + to <= n { dp[i+to][to] += dp[i][from]; dp[i+to][to] %= MOD; } } } } println!("{}", dp[n].iter().sum::<usize>() % MOD); }