結果

問題 No.1049 Zero (Exhaust)
ユーザー AEnAEn
提出日時 2022-05-19 14:42:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 181 ms / 2,000 ms
コード長 314 bytes
コンパイル時間 205 ms
コンパイル使用メモリ 81,792 KB
実行使用メモリ 148,188 KB
最終ジャッジ日時 2023-10-17 23:51:56
合計ジャッジ時間 4,772 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,420 KB
testcase_01 AC 38 ms
53,420 KB
testcase_02 AC 38 ms
53,420 KB
testcase_03 AC 137 ms
122,384 KB
testcase_04 AC 39 ms
53,420 KB
testcase_05 AC 136 ms
121,400 KB
testcase_06 AC 181 ms
148,188 KB
testcase_07 AC 53 ms
71,076 KB
testcase_08 AC 88 ms
95,348 KB
testcase_09 AC 139 ms
122,908 KB
testcase_10 AC 174 ms
146,752 KB
testcase_11 AC 177 ms
146,776 KB
testcase_12 AC 179 ms
147,772 KB
testcase_13 AC 84 ms
94,716 KB
testcase_14 AC 94 ms
96,376 KB
testcase_15 AC 136 ms
122,500 KB
testcase_16 AC 133 ms
121,456 KB
testcase_17 AC 133 ms
121,668 KB
testcase_18 AC 179 ms
146,880 KB
testcase_19 AC 137 ms
122,544 KB
testcase_20 AC 88 ms
95,300 KB
testcase_21 AC 138 ms
122,716 KB
testcase_22 AC 93 ms
96,216 KB
testcase_23 AC 180 ms
148,180 KB
testcase_24 AC 181 ms
148,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

P, K = map(int, input().split())
mod = 10**9+7
# dp:K回目の処理後にN=0 or N != 0
dp = [[0]*2 for _ in range(K+1)]
dp[0][0] = 1
for i in range(1, K+1):
    dp[i][1] = dp[i-1][1]*(2*P-2) + dp[i-1][0]*(P-1)
    dp[i][0] = dp[i-1][1]*2 + dp[i-1][0]*(P+1)
    dp[i][0] %= mod
    dp[i][1] %= mod
print(dp[-1][0])
0