結果

問題 No.1049 Zero (Exhaust)
ユーザー brthyyjpbrthyyjp
提出日時 2020-05-08 22:24:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 180 ms / 2,000 ms
コード長 294 bytes
コンパイル時間 636 ms
コンパイル使用メモリ 87,324 KB
実行使用メモリ 148,368 KB
最終ジャッジ日時 2023-09-17 03:06:50
合計ジャッジ時間 4,406 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
71,096 KB
testcase_01 AC 59 ms
71,552 KB
testcase_02 AC 59 ms
71,308 KB
testcase_03 AC 138 ms
122,548 KB
testcase_04 AC 63 ms
71,512 KB
testcase_05 AC 138 ms
121,540 KB
testcase_06 AC 176 ms
148,272 KB
testcase_07 AC 69 ms
77,068 KB
testcase_08 AC 97 ms
95,404 KB
testcase_09 AC 144 ms
122,988 KB
testcase_10 AC 174 ms
146,828 KB
testcase_11 AC 177 ms
146,684 KB
testcase_12 AC 178 ms
147,548 KB
testcase_13 AC 93 ms
94,588 KB
testcase_14 AC 101 ms
96,148 KB
testcase_15 AC 142 ms
122,676 KB
testcase_16 AC 137 ms
121,352 KB
testcase_17 AC 138 ms
121,844 KB
testcase_18 AC 177 ms
146,816 KB
testcase_19 AC 142 ms
122,568 KB
testcase_20 AC 97 ms
95,296 KB
testcase_21 AC 146 ms
122,604 KB
testcase_22 AC 101 ms
95,980 KB
testcase_23 AC 180 ms
148,232 KB
testcase_24 AC 179 ms
148,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

p, k = map(int, input().split())
mod = 10**9+7

dp = [[0]*2 for _ in range(k+1)]
dp[0][0] = 1
dp[0][1] = 0

for i in range(k):
    dp[i+1][0] = (p+1)*dp[i][0]+2*dp[i][1]
    dp[i+1][1] = (p-1)*dp[i][0]+2*(p-1)*dp[i][1]
    dp[i+1][0] %= mod
    dp[i+1][1] %= mod
#print(dp)
print(dp[k][0]%mod)
0