結果

問題 No.1049 Zero (Exhaust)
ユーザー kohei2019kohei2019
提出日時 2022-07-14 00:42:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 207 ms / 2,000 ms
コード長 238 bytes
コンパイル時間 381 ms
コンパイル使用メモリ 87,156 KB
実行使用メモリ 147,936 KB
最終ジャッジ日時 2023-09-07 11:52:02
合計ジャッジ時間 6,198 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,144 KB
testcase_01 AC 71 ms
71,116 KB
testcase_02 AC 70 ms
71,516 KB
testcase_03 AC 164 ms
121,852 KB
testcase_04 AC 72 ms
71,432 KB
testcase_05 AC 161 ms
120,996 KB
testcase_06 AC 205 ms
147,936 KB
testcase_07 AC 83 ms
76,680 KB
testcase_08 AC 114 ms
95,000 KB
testcase_09 AC 166 ms
122,656 KB
testcase_10 AC 202 ms
146,500 KB
testcase_11 AC 198 ms
146,352 KB
testcase_12 AC 204 ms
147,168 KB
testcase_13 AC 108 ms
94,356 KB
testcase_14 AC 117 ms
96,052 KB
testcase_15 AC 162 ms
122,216 KB
testcase_16 AC 159 ms
120,908 KB
testcase_17 AC 159 ms
121,096 KB
testcase_18 AC 200 ms
146,264 KB
testcase_19 AC 162 ms
122,072 KB
testcase_20 AC 113 ms
94,824 KB
testcase_21 AC 164 ms
122,604 KB
testcase_22 AC 117 ms
95,800 KB
testcase_23 AC 203 ms
147,900 KB
testcase_24 AC 207 ms
147,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

P,K = map(int,input().split())
dp = [[0,0] for i in range(K+1)]
mod = 10**9+7
dp[0][0] = 1
for i in range(1,K+1):
    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
print(dp[K][0])
0