結果
問題 | No.533 Mysterious Stairs |
ユーザー |
![]() |
提出日時 | 2019-05-23 22:19:07 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 89 ms / 5,000 ms |
コード長 | 1,357 bytes |
コンパイル時間 | 904 ms |
コンパイル使用メモリ | 112,808 KB |
最終ジャッジ日時 | 2025-01-07 03:51:46 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
ソースコード
#include <iostream> #include <cstdio> #include <algorithm> #include <vector> #include <functional> #include <queue> #include <string> #include <cstring> #include <numeric> #include <cstdlib> #include <cmath> #include <map> #include <unordered_map> #include <set> using namespace std; typedef long long ll; #define INF 10e17 // 4倍しても(4回足しても)long longを溢れない #define rep(i,n) for(int i=0; i<n; i++) #define rep_r(i,n,m) for(int i=m; i<n; i++) #define END cout << endl #define MOD 1000000007 #define pb push_back #define sorti(x) sort(x.begin(), x.end()) #define sortd(x) sort(x.begin(), x.end(), std::greater<int>()) #define debug(x) std::cerr << (x) << std::endl; #define roll(x) for (auto itr : x) { debug(itr); } template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;} template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;} int main() { int n; cin >> n; vector<vector<ll>> dp(n + 10, vector<ll>(3, 0)); dp[0][0] = 1; dp[1][0] = 1; for (int i = 0; i < n; ++i) { rep(j, 3) { rep(k, 3) { if (j == k) continue; int step = k + 1; dp[i + step][k] += dp[i][j] % MOD; } } } // rep(i, n + 1) cout << dp[i][0] << " " << dp[i][1] << " " << dp[i][2] << endl; ll ans = 0; rep(i, 3) ans += dp[n][i] % MOD; cout << ans % MOD << endl; }