結果

問題 No.1049 Zero (Exhaust)
ユーザー roarisroaris
提出日時 2020-05-14 22:45:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 216 bytes
コンパイル時間 263 ms
コンパイル使用メモリ 87,108 KB
実行使用メモリ 91,864 KB
最終ジャッジ日時 2023-10-14 08:26:54
合計ジャッジ時間 3,745 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
71,356 KB
testcase_01 AC 60 ms
71,288 KB
testcase_02 AC 59 ms
71,608 KB
testcase_03 AC 73 ms
86,776 KB
testcase_04 AC 63 ms
71,276 KB
testcase_05 AC 76 ms
84,772 KB
testcase_06 AC 79 ms
91,864 KB
testcase_07 AC 68 ms
78,012 KB
testcase_08 AC 69 ms
80,512 KB
testcase_09 AC 77 ms
87,756 KB
testcase_10 AC 79 ms
88,880 KB
testcase_11 AC 76 ms
88,888 KB
testcase_12 AC 80 ms
90,748 KB
testcase_13 AC 68 ms
79,284 KB
testcase_14 AC 71 ms
82,612 KB
testcase_15 AC 73 ms
87,108 KB
testcase_16 AC 73 ms
84,824 KB
testcase_17 AC 75 ms
85,484 KB
testcase_18 AC 77 ms
88,948 KB
testcase_19 AC 73 ms
87,032 KB
testcase_20 AC 71 ms
80,716 KB
testcase_21 AC 76 ms
87,412 KB
testcase_22 AC 72 ms
82,420 KB
testcase_23 AC 78 ms
91,660 KB
testcase_24 AC 82 ms
91,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

P, K = map(int, input().split())
dp0 = [0]*(K+1)
dp1 = [0]*(K+1)
dp0[0] = 1
MOD = 10**9+7

for i in range(K):
    dp0[i+1] = ((P+1)*dp0[i]+2*dp1[i])%MOD
    dp1[i+1] = ((P-1)*dp0[i]+2*(P-1)*dp1[i])%MOD

print(dp0[K])
0