結果

問題 No.533 Mysterious Stairs
ユーザー beetbeet
提出日時 2017-06-23 22:28:40
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 135 ms / 5,000 ms
コード長 474 bytes
コンパイル時間 1,204 ms
コンパイル使用メモリ 158,948 KB
実行使用メモリ 237,908 KB
最終ジャッジ日時 2024-04-15 00:51:50
合計ジャッジ時間 4,123 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
237,824 KB
testcase_01 AC 87 ms
237,864 KB
testcase_02 AC 62 ms
237,788 KB
testcase_03 AC 60 ms
237,696 KB
testcase_04 AC 59 ms
237,824 KB
testcase_05 AC 60 ms
237,908 KB
testcase_06 AC 59 ms
237,712 KB
testcase_07 AC 60 ms
237,824 KB
testcase_08 AC 58 ms
237,840 KB
testcase_09 AC 61 ms
237,568 KB
testcase_10 AC 61 ms
237,824 KB
testcase_11 AC 59 ms
237,756 KB
testcase_12 AC 60 ms
237,824 KB
testcase_13 AC 61 ms
237,760 KB
testcase_14 AC 61 ms
237,824 KB
testcase_15 AC 59 ms
237,792 KB
testcase_16 AC 59 ms
237,868 KB
testcase_17 AC 59 ms
237,824 KB
testcase_18 AC 61 ms
237,732 KB
testcase_19 AC 61 ms
237,776 KB
testcase_20 AC 67 ms
237,824 KB
testcase_21 AC 68 ms
237,696 KB
testcase_22 AC 83 ms
237,876 KB
testcase_23 AC 123 ms
237,716 KB
testcase_24 AC 125 ms
237,824 KB
testcase_25 AC 68 ms
237,788 KB
testcase_26 AC 115 ms
237,824 KB
testcase_27 AC 76 ms
237,748 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