結果
問題 | No.533 Mysterious Stairs |
ユーザー |
![]() |
提出日時 | 2018-09-09 06:05:56 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 56 ms / 5,000 ms |
コード長 | 756 bytes |
コンパイル時間 | 1,617 ms |
コンパイル使用メモリ | 166,660 KB |
実行使用メモリ | 34,560 KB |
最終ジャッジ日時 | 2024-12-23 02:41:15 |
合計ジャッジ時間 | 2,640 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
ソースコード
#include <bits/stdc++.h>using namespace std;using int64 = long long;using uint64 = unsigned long long;constexpr int64 MOD = 1e9 + 7;int64 table[1000001][4];int main(){cin.tie(nullptr);ios::sync_with_stdio(false);int N;cin >> N;table[0][0] = 1;for (int i = 0; i < N; i++){for (int pre = 0; pre <= 3; pre++){if (table[i][pre] == 0) continue;for (int step = 1; step <= 3; step++){if (pre != step and i + step <= N){(table[i + step][step] += table[i][pre]) %= MOD;}}}}cout << (table[N][1] + table[N][2] + table[N][3]) % MOD << endl;return 0;}