結果
問題 | No.533 Mysterious Stairs |
ユーザー |
![]() |
提出日時 | 2019-04-09 19:37:31 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 17 ms / 5,000 ms |
コード長 | 1,850 bytes |
コンパイル時間 | 10,782 ms |
コンパイル使用メモリ | 270,696 KB |
最終ジャッジ日時 | 2025-01-07 01:37:01 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
ソースコード
#pragma GCC optimize ("O3")#pragma GCC target ("avx")#include "bits/stdc++.h" // define macro "/D__MAI"using namespace std;typedef long long int ll;#define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout<<e<<" ";}cout<<endl;#define debugm(m) printf("L%d %s is..\n",__LINE__,#m);for(auto v:m){for(auto e:v){cout<<e<<" ";}cout<<endl;}#define debuga(m,w) printf("L%d %s is => ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;#define debugaa(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[x][y]<<" ";}cout<<endl;}#define debugaar(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[y][x]<<" ";}cout<<endl;}#define ALL(v) (v).begin(),(v).end()#define repeat(l) for(auto cnt=0;cnt<(l);++cnt)#define iterate(b,e) for(auto cnt=(b);cnt!=(e);++cnt)#define MD 1000000007ll#define PI 3.1415926535897932384626433832795template<typename T1, typename T2>ostream& operator <<(ostream &o, const pair<T1, T2> p) { o << "(" << p.first << ":" << p.second << ")"; return o; }ll solve_MLE(int n) {vector<array<ll, 4>> dp(n + 4);dp[1][1] = 1; // 1jump で 1step 登る.次は 1jump は使えない.dp[2][2] = 1; // 2jump で 2step 登る.次は 2jump は使えない.dp[3][3] = 1; // 3jump で 3step 登る.次は 3jump は使えない.for (int i = 1; i < n; ++i) {// 1jumpする.dp[i + 1][1] = (dp[i + 1][1] + (dp[i][2] + dp[i][3])) % MD;// 2jumpする.dp[i + 2][2] = (dp[i + 2][2] + (dp[i][1] + dp[i][3])) % MD;// 3jumpする.dp[i + 3][3] = (dp[i + 3][3] + (dp[i][1] + dp[i][2])) % MD;}return (dp[n][1] + dp[n][2] + dp[n][3]) % MD;}int main() {int n;cin >> n;cout << solve_MLE(n) << endl;}