結果

問題 No.533 Mysterious Stairs
ユーザー CleyLCleyL
提出日時 2020-03-03 14:46:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 45 ms / 5,000 ms
コード長 515 bytes
コンパイル時間 587 ms
コンパイル使用メモリ 64,128 KB
実行使用メモリ 34,688 KB
最終ジャッジ日時 2024-04-22 00:03:43
合計ジャッジ時間 1,738 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 6 ms
6,912 KB
testcase_21 AC 7 ms
7,424 KB
testcase_22 AC 17 ms
15,488 KB
testcase_23 AC 42 ms
34,304 KB
testcase_24 AC 45 ms
34,688 KB
testcase_25 AC 6 ms
6,912 KB
testcase_26 AC 36 ms
30,464 KB
testcase_27 AC 12 ms
11,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
const long long mod = 1000000007;
long long dp[1000005][4];
int main(){
    int n;cin>>n;
    dp[1][1] = 1;
    dp[2][2] = 1;
    dp[3][3] = 1;
    
    for(int i = 1; n >= i; i++){
        for(int j = 1; 4 > j; j++){
            if(j!=1)dp[i+1][1] = (dp[i+1][1]+dp[i][j])%mod;
            if(j!=2)dp[i+2][2] = (dp[i+2][2]+dp[i][j])%mod;
            if(j!=3)dp[i+3][3] = (dp[i+3][3]+dp[i][j])%mod;
        }
    }
    cout << (dp[n][1]+dp[n][2]+dp[n][3])%mod << endl;
    
}
0