結果

問題 No.1049 Zero (Exhaust)
ユーザー kappybarkappybar
提出日時 2020-05-08 21:57:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 604 bytes
コンパイル時間 1,261 ms
コンパイル使用メモリ 168,312 KB
実行使用メモリ 57,856 KB
最終ジャッジ日時 2023-09-17 02:44:26
合計ジャッジ時間 3,168 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 60 ms
40,408 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 43 ms
33,616 KB
testcase_06 AC 75 ms
57,856 KB
testcase_07 AC 11 ms
9,920 KB
testcase_08 AC 22 ms
18,964 KB
testcase_09 AC 56 ms
43,904 KB
testcase_10 AC 65 ms
47,624 KB
testcase_11 AC 62 ms
47,936 KB
testcase_12 AC 72 ms
54,816 KB
testcase_13 AC 18 ms
14,648 KB
testcase_14 AC 32 ms
26,284 KB
testcase_15 AC 52 ms
41,232 KB
testcase_16 AC 43 ms
33,912 KB
testcase_17 AC 45 ms
35,296 KB
testcase_18 AC 66 ms
48,644 KB
testcase_19 AC 60 ms
41,468 KB
testcase_20 AC 26 ms
18,700 KB
testcase_21 AC 59 ms
42,732 KB
testcase_22 AC 32 ms
25,328 KB
testcase_23 AC 78 ms
57,724 KB
testcase_24 AC 80 ms
57,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;

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