結果
問題 | No.533 Mysterious Stairs |
ユーザー |
|
提出日時 | 2021-11-19 00:12:29 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 61 ms / 5,000 ms |
コード長 | 677 bytes |
コンパイル時間 | 2,142 ms |
コンパイル使用メモリ | 193,336 KB |
最終ジャッジ日時 | 2025-01-25 19:27:36 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
ソースコード
#include <bits/stdc++.h>using namespace std;const long long int MOD = 1e9 + 7;long long int dp[1000001][4];int main(void){cin.tie(0);ios::sync_with_stdio(false);dp[0][0] = 1;int n;cin >> n;for(int i=0;i<n;i++){for(int j=0;j<=3;j++){if(dp[i][j]==0) continue;for(int k=1;k<=3;k++){if(j==k) continue;if(i+k > n) continue;dp[i+k][k] += dp[i][j];dp[i+k][k]%=MOD;}}}long long int res = dp[n][0] + dp[n][1] + dp[n][2] + dp[n][3];res%=MOD;cout << res << '\n';return 0;}