結果

問題 No.533 Mysterious Stairs
ユーザー ikeyanabcd894ikeyanabcd894
提出日時 2019-04-28 09:03:53
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 43 ms / 5,000 ms
コード長 449 bytes
コンパイル時間 1,156 ms
コンパイル使用メモリ 143,736 KB
実行使用メモリ 42,424 KB
最終ジャッジ日時 2023-08-21 06:59:46
合計ジャッジ時間 2,765 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,384 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 7 ms
9,464 KB
testcase_21 AC 8 ms
9,476 KB
testcase_22 AC 18 ms
19,732 KB
testcase_23 AC 43 ms
42,236 KB
testcase_24 AC 43 ms
42,424 KB
testcase_25 AC 7 ms
9,476 KB
testcase_26 AC 38 ms
38,196 KB
testcase_27 AC 13 ms
13,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
long long N;
long long mod=1000000007;
long long memo[1000009][5];

int main(){
  cin >> N;
  memo[1][1]=1;
  memo[2][2]=1;
  memo[3][3]=1;
  memo[3][1]=1;
  memo[3][2]=1;
  for(int i=4;i<=N;i++){
    memo[i][1]=(memo[i-1][2]+memo[i-1][3])%mod;
    memo[i][2]=(memo[i-2][1]+memo[i-2][3])%mod;
    memo[i][3]=(memo[i-3][1]+memo[i-3][2])%mod;
  }
  cout << (memo[N][1]+memo[N][2]+memo[N][3])%mod << endl;
}
0