結果

問題 No.1049 Zero (Exhaust)
ユーザー 👑 deuteridayodeuteridayo
提出日時 2020-05-21 12:44:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 389 bytes
コンパイル時間 1,680 ms
コンパイル使用メモリ 167,224 KB
実行使用メモリ 57,948 KB
最終ジャッジ日時 2024-04-09 23:21:33
合計ジャッジ時間 3,865 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 56 ms
40,644 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 47 ms
33,684 KB
testcase_06 AC 82 ms
57,876 KB
testcase_07 AC 13 ms
9,912 KB
testcase_08 AC 27 ms
19,220 KB
testcase_09 AC 63 ms
44,132 KB
testcase_10 AC 68 ms
47,828 KB
testcase_11 AC 69 ms
47,972 KB
testcase_12 AC 80 ms
54,956 KB
testcase_13 AC 21 ms
15,116 KB
testcase_14 AC 37 ms
26,524 KB
testcase_15 AC 59 ms
41,320 KB
testcase_16 AC 48 ms
34,080 KB
testcase_17 AC 50 ms
35,608 KB
testcase_18 AC 70 ms
48,720 KB
testcase_19 AC 59 ms
41,608 KB
testcase_20 AC 26 ms
18,960 KB
testcase_21 AC 60 ms
42,912 KB
testcase_22 AC 34 ms
25,396 KB
testcase_23 AC 82 ms
57,948 KB
testcase_24 AC 83 ms
57,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int main(){
    long p,k;
    cin >> p >> k;
    long const mod = 1e9+7;
    vector<vector<long> >dp(k+1,vector<long>(2)); //0:0 1:非0
    dp[0][0] = 1;
    for(int i=1;i<=k;i++){
        dp[i][0] = (dp[i-1][0] * (p+1) + dp[i-1][1]*2)%mod;
        dp[i][1] = (dp[i-1][0] * (p-1) + dp[i-1][1]*(2*p-2))%mod;
    }
    cout << dp[k][0] << endl;
}
0