結果

問題 No.533 Mysterious Stairs
ユーザー recososorecososo
提出日時 2020-02-26 14:51:19
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 25 ms / 5,000 ms
コード長 567 bytes
コンパイル時間 1,630 ms
コンパイル使用メモリ 164,752 KB
実行使用メモリ 15,100 KB
最終ジャッジ日時 2023-08-03 18:15:03
合計ジャッジ時間 3,001 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,384 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,384 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 5 ms
4,804 KB
testcase_21 AC 5 ms
4,788 KB
testcase_22 AC 11 ms
7,968 KB
testcase_23 AC 24 ms
14,972 KB
testcase_24 AC 25 ms
15,100 KB
testcase_25 AC 5 ms
4,676 KB
testcase_26 AC 23 ms
13,508 KB
testcase_27 AC 8 ms
6,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int main(){
    int n;cin >> n;
    int dp[n+1][3];
    memset(dp,0,sizeof(dp));
    dp[1][0]=1;
    dp[2][1]=1;
    dp[3][2]=1;
    for(int i=1;i<n;i++){
        for(int j=0;j<3;j++){
            if(dp[i][j]){
                for(int k=0;k<3;k++){
                    if(j!=k){
                        dp[i+k+1][k]+=dp[i][j];
                        dp[i+k+1][k]%=mod;
                    }
                }
            }
        }
    }
    cout << ((dp[n][0]+dp[n][1])%mod+dp[n][2])%mod << endl;
}
0