結果

問題 No.533 Mysterious Stairs
ユーザー beetbeet
提出日時 2017-06-23 22:28:40
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 171 ms / 5,000 ms
コード長 474 bytes
コンパイル時間 1,446 ms
コンパイル使用メモリ 144,332 KB
実行使用メモリ 238,008 KB
最終ジャッジ日時 2023-07-27 12:44:16
合計ジャッジ時間 6,027 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
237,720 KB
testcase_01 AC 61 ms
237,716 KB
testcase_02 AC 62 ms
237,788 KB
testcase_03 AC 62 ms
237,720 KB
testcase_04 AC 62 ms
237,716 KB
testcase_05 AC 61 ms
237,940 KB
testcase_06 AC 63 ms
237,792 KB
testcase_07 AC 62 ms
237,796 KB
testcase_08 AC 94 ms
237,796 KB
testcase_09 AC 94 ms
237,792 KB
testcase_10 AC 92 ms
237,800 KB
testcase_11 AC 96 ms
237,724 KB
testcase_12 AC 91 ms
238,008 KB
testcase_13 AC 94 ms
237,992 KB
testcase_14 AC 93 ms
237,720 KB
testcase_15 AC 95 ms
237,720 KB
testcase_16 AC 92 ms
237,736 KB
testcase_17 AC 96 ms
237,716 KB
testcase_18 AC 96 ms
237,936 KB
testcase_19 AC 97 ms
237,724 KB
testcase_20 AC 100 ms
237,720 KB
testcase_21 AC 105 ms
237,728 KB
testcase_22 AC 119 ms
237,720 KB
testcase_23 AC 162 ms
237,796 KB
testcase_24 AC 171 ms
237,724 KB
testcase_25 AC 98 ms
237,772 KB
testcase_26 AC 149 ms
237,860 KB
testcase_27 AC 111 ms
237,736 KB
権限があれば一括ダウンロードができます

ソースコード

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