結果

問題 No.533 Mysterious Stairs
ユーザー Naoyk1212Naoyk1212
提出日時 2017-06-24 00:04:43
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 742 bytes
コンパイル時間 1,273 ms
コンパイル使用メモリ 159,388 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 01:11:53
合計ジャッジ時間 3,086 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,812 KB
testcase_01 AC 3 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 3 ms
6,940 KB
testcase_19 AC 3 ms
6,940 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;

int main(){
    int n;
    cin >> n;
    int dp[100010][3];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++){
            dp[i][j] = 0;
        }
    }
    dp[1][0] = 1;
    dp[2][1] = 1;
    dp[3][2] = 1;

    for(int i = 0; i < n; i++){
      for(int j = 0; j < 3; j++){
        for(int k = 0; k < 3; k++){
          //cerr << i << " " << j << " " << k << " " <<  dp[i][j] << endl;
          if(dp[i][j] > 0 && j != k){
            dp[i + k + 1][k] = (dp[i + k + 1][k] + dp[i][j]) % mod;
          }
        }
      }
    }

    long long ans = 0;
    for(int i = 0; i < 3; i++){
        ans = (ans + dp[n][i]) % mod;
    }
    cout << ans << endl;

}
0