結果

問題 No.1049 Zero (Exhaust)
ユーザー kurimupykurimupy
提出日時 2020-06-12 22:55:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 439 bytes
コンパイル時間 2,212 ms
コンパイル使用メモリ 86,600 KB
実行使用メモリ 91,836 KB
最終ジャッジ日時 2023-09-06 11:04:28
合計ジャッジ時間 3,576 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
71,032 KB
testcase_01 AC 66 ms
71,368 KB
testcase_02 AC 62 ms
71,404 KB
testcase_03 AC 93 ms
86,564 KB
testcase_04 AC 63 ms
71,140 KB
testcase_05 AC 79 ms
84,848 KB
testcase_06 AC 85 ms
91,836 KB
testcase_07 AC 72 ms
77,980 KB
testcase_08 AC 75 ms
80,692 KB
testcase_09 AC 80 ms
87,740 KB
testcase_10 AC 83 ms
88,596 KB
testcase_11 AC 85 ms
88,916 KB
testcase_12 AC 85 ms
90,988 KB
testcase_13 AC 72 ms
79,532 KB
testcase_14 AC 75 ms
82,872 KB
testcase_15 AC 81 ms
86,932 KB
testcase_16 AC 77 ms
84,632 KB
testcase_17 AC 78 ms
85,148 KB
testcase_18 AC 85 ms
89,156 KB
testcase_19 AC 81 ms
86,956 KB
testcase_20 AC 73 ms
80,720 KB
testcase_21 AC 79 ms
87,512 KB
testcase_22 AC 74 ms
82,576 KB
testcase_23 AC 84 ms
91,796 KB
testcase_24 AC 84 ms
91,668 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# problem 2
P, K = map(int, input().split())
# dp[K] = K 回目の操作を終えた時に mod P で 0
# ex_dp[K] = K 回目の操作を終えた時に mod P で 0 でない
dp = [0 for i in range(K+1)]
ex_dp = [0 for i in range(K+1)]
dp[0] = 1
mod = 10**9 + 7
for i in range(1, K+1):
    dp[i] = dp[i-1]*(P+1) + ex_dp[i-1]*2
    ex_dp[i] = dp[i-1]*(P-1) + ex_dp[i-1]*(2*P-2)
    dp[i] %= mod
    ex_dp[i] %= mod
ans = dp[K]
print(ans)
0