結果
問題 | No.533 Mysterious Stairs |
ユーザー |
![]() |
提出日時 | 2017-06-23 23:52:20 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 91 ms / 5,000 ms |
コード長 | 641 bytes |
コンパイル時間 | 317 ms |
コンパイル使用メモリ | 39,292 KB |
実行使用メモリ | 73,108 KB |
最終ジャッジ日時 | 2024-10-04 08:07:33 |
合計ジャッジ時間 | 1,597 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
ソースコード
#include<cstdio>#include<vector>using namespace std;using ll=long long;using vll=vector<ll>;using vvll=vector<vll>;#define MOD 1000000007int main(void){int n;while(scanf("%d", &n)==1){if(n<=2){printf("1\n");continue;}vvll dp(n+3);for(auto&dpe:dp) dpe.assign(4, 0);dp[3][3]=1;dp[2][2]=1;dp[1][1]=1;for(int i=1;i<n;i++){for(int j=1;j<=3;j++){for(int k=1;k<=3;k++){if(j==k) continue;dp[i+k][k]=(dp[i+k][k]+dp[i][j])%MOD;}}}ll ans=0;for(int i=1;i<=3;i++){ans=(ans+dp[n][i])%MOD;}printf("%d\n", (int)ans);}return 0;}