結果
問題 | No.533 Mysterious Stairs |
ユーザー |
![]() |
提出日時 | 2017-06-24 00:02:24 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 19 ms / 5,000 ms |
コード長 | 370 bytes |
コンパイル時間 | 536 ms |
コンパイル使用メモリ | 64,640 KB |
実行使用メモリ | 34,752 KB |
最終ジャッジ日時 | 2024-10-04 08:12:27 |
合計ジャッジ時間 | 1,407 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
ソースコード
#include <iostream> using namespace std; int main(){ int n; cin >> n; int64_t dp[n + 1][4]{}; dp[1][1] = dp[2][2] = 1; if(1 < n) dp[3][3] = 1; for(int i = 3; i <= n; i++) for(int j = 1; j <= 3; j++) (dp[i][j] += dp[i - j][1] + dp[i - j][2] + dp[i - j][3] - dp[i - j][j]) %= int64_t(1e9 + 7); cout << (dp[n][1] + dp[n][2] + dp[n][3]) % int64_t(1e9 + 7) << endl; }