結果

問題 No.1049 Zero (Exhaust)
ユーザー amyuamyu
提出日時 2020-05-08 21:46:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,480 ms / 2,000 ms
コード長 226 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 10,624 KB
実行使用メモリ 157,104 KB
最終ジャッジ日時 2023-09-17 02:30:47
合計ジャッジ時間 19,954 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
7,772 KB
testcase_01 AC 12 ms
7,880 KB
testcase_02 AC 12 ms
7,776 KB
testcase_03 AC 940 ms
109,696 KB
testcase_04 AC 13 ms
7,788 KB
testcase_05 AC 754 ms
90,972 KB
testcase_06 AC 1,443 ms
156,964 KB
testcase_07 AC 161 ms
26,492 KB
testcase_08 AC 384 ms
51,952 KB
testcase_09 AC 1,059 ms
119,760 KB
testcase_10 AC 1,161 ms
129,800 KB
testcase_11 AC 1,163 ms
130,256 KB
testcase_12 AC 1,417 ms
149,164 KB
testcase_13 AC 277 ms
39,668 KB
testcase_14 AC 569 ms
71,752 KB
testcase_15 AC 946 ms
111,808 KB
testcase_16 AC 753 ms
92,008 KB
testcase_17 AC 785 ms
95,936 KB
testcase_18 AC 1,203 ms
132,056 KB
testcase_19 AC 984 ms
112,872 KB
testcase_20 AC 375 ms
50,976 KB
testcase_21 AC 1,032 ms
115,844 KB
testcase_22 AC 553 ms
68,552 KB
testcase_23 AC 1,470 ms
157,020 KB
testcase_24 AC 1,480 ms
157,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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