結果

問題 No.1049 Zero (Exhaust)
ユーザー tktk_snsntktk_snsn
提出日時 2020-12-16 18:55:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 430 bytes
コンパイル時間 625 ms
コンパイル使用メモリ 81,764 KB
実行使用メモリ 59,272 KB
最終ジャッジ日時 2023-10-20 09:46:30
合計ジャッジ時間 3,028 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,288 KB
testcase_01 AC 36 ms
53,288 KB
testcase_02 AC 35 ms
53,288 KB
testcase_03 AC 50 ms
59,272 KB
testcase_04 AC 35 ms
53,288 KB
testcase_05 AC 51 ms
59,272 KB
testcase_06 AC 55 ms
59,272 KB
testcase_07 AC 43 ms
59,272 KB
testcase_08 AC 48 ms
59,272 KB
testcase_09 AC 50 ms
59,272 KB
testcase_10 AC 50 ms
59,272 KB
testcase_11 AC 50 ms
59,272 KB
testcase_12 AC 53 ms
59,272 KB
testcase_13 AC 43 ms
59,272 KB
testcase_14 AC 46 ms
59,272 KB
testcase_15 AC 49 ms
59,272 KB
testcase_16 AC 47 ms
59,272 KB
testcase_17 AC 48 ms
59,272 KB
testcase_18 AC 51 ms
59,272 KB
testcase_19 AC 50 ms
59,272 KB
testcase_20 AC 44 ms
59,272 KB
testcase_21 AC 49 ms
59,272 KB
testcase_22 AC 45 ms
59,272 KB
testcase_23 AC 52 ms
59,272 KB
testcase_24 AC 52 ms
59,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

zero = 1
other = 0  # 1, 2, ... P-1それぞれの状態数(ぜんぶいっしょ)
for _ in range(K):
    n0 = 0
    n1 = 0

    # mult 0
    n0 += zero + (p - 1) * other
    # mult 1,2,..p-1
    n0 += zero * (p - 1)
    n1 += other * (p - 1)

    # add
    n0 += zero + (p - 1) * other
    n1 += zero + (p - 1) * other

    zero = n0 % mod
    other = n1 % mod

print(zero)
0