結果

問題 No.533 Mysterious Stairs
ユーザー tadanoningentadanoningen
提出日時 2020-10-23 07:29:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 128 ms / 5,000 ms
コード長 596 bytes
コンパイル時間 1,794 ms
コンパイル使用メモリ 169,228 KB
実行使用メモリ 73,600 KB
最終ジャッジ日時 2023-09-28 15:04:11
合計ジャッジ時間 6,041 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
73,424 KB
testcase_01 AC 90 ms
73,516 KB
testcase_02 AC 90 ms
73,424 KB
testcase_03 AC 89 ms
73,308 KB
testcase_04 AC 88 ms
73,432 KB
testcase_05 AC 90 ms
73,392 KB
testcase_06 AC 89 ms
73,600 KB
testcase_07 AC 90 ms
73,520 KB
testcase_08 AC 89 ms
73,420 KB
testcase_09 AC 89 ms
73,312 KB
testcase_10 AC 89 ms
73,452 KB
testcase_11 AC 88 ms
73,416 KB
testcase_12 AC 90 ms
73,520 KB
testcase_13 AC 89 ms
73,440 KB
testcase_14 AC 88 ms
73,420 KB
testcase_15 AC 89 ms
73,264 KB
testcase_16 AC 88 ms
73,376 KB
testcase_17 AC 89 ms
73,420 KB
testcase_18 AC 90 ms
73,304 KB
testcase_19 AC 89 ms
73,248 KB
testcase_20 AC 93 ms
73,392 KB
testcase_21 AC 93 ms
73,264 KB
testcase_22 AC 103 ms
73,304 KB
testcase_23 AC 128 ms
73,440 KB
testcase_24 AC 127 ms
73,376 KB
testcase_25 AC 94 ms
73,428 KB
testcase_26 AC 122 ms
73,360 KB
testcase_27 AC 98 ms
73,444 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define INF 1000000007

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<vector<long long>> dp(1000100,vector<long long>(4,0));
    dp[0][0] = 1;
    for(int i=0;i < n;i++){
        for(int j=0;j < 4;j++){
            for(int k=1;k < 4;k++){
                if(j != k){
                    dp[i+k][k] += dp[i][j] % INF;
                    dp[i+k][k] %= INF;
                }
            }
        }
    }
    long long ans = 0;
    for(int i=0;i < 4;i++){
      ans += dp[n][i] % INF;
      ans %= INF;
    }
    cout << ans << endl;
    return 0;
}
0