結果
| 問題 |
No.533 Mysterious Stairs
|
| コンテスト | |
| ユーザー |
dnish
|
| 提出日時 | 2017-06-23 23:01:05 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 13 ms / 5,000 ms |
| コード長 | 540 bytes |
| コンパイル時間 | 1,453 ms |
| コンパイル使用メモリ | 167,916 KB |
| 実行使用メモリ | 26,908 KB |
| 最終ジャッジ日時 | 2024-10-04 07:50:32 |
| 合計ジャッジ時間 | 2,327 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 28 |
ソースコード
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int)N;i++)
#define p(s) cout<<(s)<<endl
#define ck(n,a,b) ((a)<=(n)&&(n)<=(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const ll mod=1e9+7;
ll dp[1000010][3];
int main() {
int n;
cin>>n;
dp[1][0]=1;
dp[2][1]=1;
dp[3][2]=1;
dp[3][1]=1;
dp[3][0]=1;
REP(i,4,n+1){
dp[i][0]=(dp[i-1][1]+dp[i-1][2])%mod;
dp[i][1]=(dp[i-2][0]+dp[i-2][2])%mod;
dp[i][2]=(dp[i-3][0]+dp[i-3][1])%mod;
}
p((dp[n][0]+dp[n][1]+dp[n][2])%mod);
return 0;
}
dnish