結果

問題 No.533 Mysterious Stairs
ユーザー beet
提出日時 2017-06-23 22:28:40
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 186 ms / 5,000 ms
コード長 474 bytes
コンパイル時間 1,048 ms
コンパイル使用メモリ 158,800 KB
実行使用メモリ 237,880 KB
最終ジャッジ日時 2024-10-04 07:33:47
合計ジャッジ時間 5,715 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
int dp[3][10000200];
int MOD=1000000007LL;
signed main(){
  memset(dp,0,sizeof(dp));
  int n;
  cin>>n;
  for(int i=0;i<3;i++) dp[i][i+1]=1;
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
	if(j==k) continue;
	(dp[k][i+k+1]+=dp[j][i])%=MOD;
      }
    }
  }
  int ans=0;
  (ans+=dp[0][n])%=MOD;
  (ans+=dp[1][n])%=MOD;
  (ans+=dp[2][n])%=MOD;
  cout<<ans<<endl;
  return 0;
}
0