結果

問題 No.1049 Zero (Exhaust)
ユーザー stngstng
提出日時 2020-05-08 22:32:13
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 931 ms / 2,000 ms
コード長 310 bytes
コンパイル時間 237 ms
コンパイル使用メモリ 10,564 KB
実行使用メモリ 7,976 KB
最終ジャッジ日時 2023-09-17 03:09:56
合計ジャッジ時間 13,386 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,836 KB
testcase_01 AC 15 ms
7,952 KB
testcase_02 AC 15 ms
7,908 KB
testcase_03 AC 599 ms
7,872 KB
testcase_04 AC 15 ms
7,816 KB
testcase_05 AC 490 ms
7,812 KB
testcase_06 AC 853 ms
7,812 KB
testcase_07 AC 121 ms
7,836 KB
testcase_08 AC 262 ms
7,808 KB
testcase_09 AC 646 ms
7,808 KB
testcase_10 AC 730 ms
7,972 KB
testcase_11 AC 735 ms
7,804 KB
testcase_12 AC 887 ms
7,804 KB
testcase_13 AC 194 ms
7,816 KB
testcase_14 AC 378 ms
7,944 KB
testcase_15 AC 606 ms
7,952 KB
testcase_16 AC 486 ms
7,936 KB
testcase_17 AC 502 ms
7,820 KB
testcase_18 AC 745 ms
7,832 KB
testcase_19 AC 626 ms
7,792 KB
testcase_20 AC 259 ms
7,816 KB
testcase_21 AC 698 ms
7,976 KB
testcase_22 AC 378 ms
7,904 KB
testcase_23 AC 931 ms
7,736 KB
testcase_24 AC 915 ms
7,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

zero = 1
notzero = 0

for i in range(k):
    zero_old = zero
    notzero_old = notzero
    zero = zero_old * (p+1) + notzero_old * 2
    zero %= mod
    notzero = zero_old * (p-1) + notzero_old * (2*p-2)
    notzero %= mod
    #print(zero,notzero)

print(zero%mod)
0