結果

問題 No.533 Mysterious Stairs
ユーザー どららどらら
提出日時 2017-06-23 23:09:10
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 760 bytes
コンパイル時間 1,436 ms
コンパイル使用メモリ 162,828 KB
実行使用メモリ 15,432 KB
最終ジャッジ日時 2024-04-15 01:01:54
合計ジャッジ時間 2,239 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,624 KB
testcase_01 AC 2 ms
7,752 KB
testcase_02 AC 2 ms
7,624 KB
testcase_03 AC 2 ms
7,752 KB
testcase_04 AC 2 ms
7,880 KB
testcase_05 AC 3 ms
7,752 KB
testcase_06 AC 2 ms
7,748 KB
testcase_07 AC 3 ms
7,752 KB
testcase_08 AC 2 ms
7,624 KB
testcase_09 AC 2 ms
7,752 KB
testcase_10 AC 2 ms
7,756 KB
testcase_11 AC 2 ms
7,748 KB
testcase_12 AC 3 ms
7,752 KB
testcase_13 AC 2 ms
7,748 KB
testcase_14 AC 3 ms
7,756 KB
testcase_15 AC 2 ms
7,628 KB
testcase_16 AC 2 ms
7,752 KB
testcase_17 AC 2 ms
7,748 KB
testcase_18 AC 3 ms
7,752 KB
testcase_19 AC 2 ms
7,876 KB
testcase_20 AC 4 ms
8,136 KB
testcase_21 AC 3 ms
8,264 KB
testcase_22 AC 6 ms
9,420 KB
testcase_23 AC 15 ms
15,432 KB
testcase_24 AC 15 ms
15,300 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007

int dp[3][1000005];

int main(){
  int N;
  cin >> N;
  
  rep(i,N){
    if(i==0){
      dp[0][1] = 1;
      dp[1][2] = 1;
      dp[2][3] = 1;
    }else{
      dp[0][i+1] += dp[1][i] + dp[2][i];
      dp[0][i+1] %= MOD;
      dp[1][i+2] += dp[0][i] + dp[2][i];
      dp[1][i+2] %= MOD;
      dp[2][i+3] += dp[0][i] + dp[1][i];
      dp[2][i+3] %= MOD;
    }
  }
  cout << (dp[0][N] + dp[1][N] + dp[2][N])%MOD << endl;
  
  return 0;
}

0