結果
問題 | No.533 Mysterious Stairs |
ユーザー |
![]() |
提出日時 | 2017-09-29 10:50:56 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 51 ms / 5,000 ms |
コード長 | 1,077 bytes |
コンパイル時間 | 1,412 ms |
コンパイル使用メモリ | 167,444 KB |
実行使用メモリ | 34,688 KB |
最終ジャッジ日時 | 2024-11-15 19:48:01 |
合計ジャッジ時間 | 2,522 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define DUMP(x) cerr << #x << "=" << x << endl#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl#define BINARY(x) static_cast<bitset<16> >(x)#define rep(i,n) for(int i=0;i<(int)(n);i++)#define REP(i,m,n) for (int i=m;i<(int)(n);i++)#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))#define ALL(a) (a).begin(),(a).end()typedef long long ll;const int INF = 1e9;const ll INFLL = 1e18;typedef pair<int, int> PII;int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};const ll MOD = 1e9 + 7;const ll MAX_N = 1e6 + 1;ll dp[MAX_N][4];int main(){ios::sync_with_stdio(false);int N; cin >> N;dp[1][1] = 1;dp[2][2] = 1;dp[3][3] = 1;for (int i=0; i<N; i++) {for (int j=1; j<=3; j++) {for (int k=1; k<=3; k++) {if (j == k) continue;(dp[i+j][j] += dp[i][k]) %= MOD;}}}cout << (((dp[N][1] + dp[N][2]) % MOD) + dp[N][3]) % MOD << endl;}