結果

問題 No.1049 Zero (Exhaust)
ユーザー simkarensimkaren
提出日時 2020-05-27 11:53:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 524 bytes
コンパイル時間 1,973 ms
コンパイル使用メモリ 180,852 KB
実行使用メモリ 57,964 KB
最終ジャッジ日時 2024-04-21 05:08:44
合計ジャッジ時間 4,005 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 64 ms
40,496 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 49 ms
33,612 KB
testcase_06 AC 86 ms
57,860 KB
testcase_07 AC 13 ms
9,984 KB
testcase_08 AC 27 ms
19,256 KB
testcase_09 AC 64 ms
44,192 KB
testcase_10 AC 70 ms
47,800 KB
testcase_11 AC 70 ms
48,072 KB
testcase_12 AC 82 ms
55,012 KB
testcase_13 AC 21 ms
14,844 KB
testcase_14 AC 37 ms
26,484 KB
testcase_15 AC 61 ms
41,340 KB
testcase_16 AC 52 ms
34,088 KB
testcase_17 AC 53 ms
35,460 KB
testcase_18 AC 72 ms
48,816 KB
testcase_19 AC 63 ms
41,672 KB
testcase_20 AC 25 ms
18,912 KB
testcase_21 AC 62 ms
42,752 KB
testcase_22 AC 36 ms
25,356 KB
testcase_23 AC 88 ms
57,964 KB
testcase_24 AC 100 ms
57,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("O3", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

constexpr ll mod = 1000000007LL;

int main(void){
    int p, k; cin >> p >> k;
    vector<vector<ll>> dp(k + 1, vector<ll>(2, 0LL));
    dp[0][0] = 1;
    for (int i = 1; i <= k; ++i){
        dp[i][0] = ((p - 1) * dp[i - 1][1] % mod * 2 + (p + 1) * dp[i - 1][0] % mod) % mod;
        dp[i][1] = (dp[i - 1][0] + 2 * (p - 1) % mod * dp[i - 1][1] % mod) % mod;
    }
    cout << dp[k][0] << endl;
    return 0;
}
0