結果
| 問題 |
No.533 Mysterious Stairs
|
| コンテスト | |
| ユーザー |
hiyokko2
|
| 提出日時 | 2017-06-24 12:36:42 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 39 ms / 5,000 ms |
| コード長 | 889 bytes |
| コンパイル時間 | 1,292 ms |
| コンパイル使用メモリ | 157,924 KB |
| 実行使用メモリ | 26,880 KB |
| 最終ジャッジ日時 | 2024-10-04 05:22:52 |
| 合計ジャッジ時間 | 2,308 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 28 |
ソースコード
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;
typedef vector<int> V;
typedef vector<V> VV;
const int INF = 1e9;
int dp[1000101][3];
signed main()
{
int N;
cin >> N;
dp[1][0] = 1; //0が1段、1が2段、2が3段
//dp[1][1] = dp[1][2] = 0;
dp[2][1] = 1;
dp[3][0] = 1;
dp[3][1] = 1;
dp[3][2] = 1;
for (int i=1; i<N; i++) {
REP(j,3) { //今見ている
REP(k,3) {
if (j == k) continue;
if (i + k + 1 >= 4) {
dp[i+k+1][k] += dp[i][j];
dp[i+k+1][k] %= MOD;
}
}
}
}
int ans = 0;
REP(i,3) {
ans += dp[N][i];
ans %= MOD;
}
cout << ans << endl;
}
hiyokko2