結果
問題 | No.533 Mysterious Stairs |
ユーザー |
![]() |
提出日時 | 2017-06-23 22:47:11 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 42 ms / 5,000 ms |
コード長 | 910 bytes |
コンパイル時間 | 1,228 ms |
コンパイル使用メモリ | 158,724 KB |
実行使用メモリ | 26,880 KB |
最終ジャッジ日時 | 2024-10-04 07:43:37 |
合計ジャッジ時間 | 2,218 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
ソースコード
#include <bits/stdc++.h> #define rep(i, a, n) for(int i = a; i < n; i++) #define repb(i, a, b) for(int i = a; i >= b; i--) #define all(a) a.begin(), a.end() #define o(a) cout << a << endl #define int long long #define fi first #define se second using namespace std; typedef pair<int, int> P; const int mod = 1e9 + 7; int dp[1000010][3]; signed main(){ int n; cin >> n; dp[1][0] = 1; dp[2][1] = 1; dp[3][2] = 1; // rep(i, 0, 3) dp[0][i] = 1; rep(i, 1, n + 1){ rep(j, 0, 3){ rep(k, 0, 3){ if(j == k || i - (j + 1) < 0) continue; dp[i][j] = (dp[i][j] + dp[i - (j + 1)][k]) % mod; } } } // rep(i, 0, n + 1){ // rep(j, 0, 3){ // cout << dp[i][j] << " "; // } // cout << endl; // } int ans = 0; rep(i, 0, 3) ans += dp[n][i]; cout << ans % mod << endl; }