結果

問題 No.1049 Zero (Exhaust)
ユーザー yuly3yuly3
提出日時 2020-07-15 22:36:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 452 bytes
コンパイル時間 146 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 73,600 KB
最終ジャッジ日時 2024-05-02 04:23:37
合計ジャッジ時間 2,683 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
51,584 KB
testcase_01 AC 36 ms
51,840 KB
testcase_02 AC 37 ms
51,840 KB
testcase_03 AC 71 ms
68,480 KB
testcase_04 AC 35 ms
51,584 KB
testcase_05 AC 64 ms
66,816 KB
testcase_06 AC 86 ms
73,344 KB
testcase_07 AC 48 ms
60,032 KB
testcase_08 AC 54 ms
62,592 KB
testcase_09 AC 78 ms
69,760 KB
testcase_10 AC 77 ms
70,656 KB
testcase_11 AC 78 ms
70,656 KB
testcase_12 AC 83 ms
72,704 KB
testcase_13 AC 52 ms
61,440 KB
testcase_14 AC 62 ms
64,768 KB
testcase_15 AC 72 ms
68,736 KB
testcase_16 AC 66 ms
66,688 KB
testcase_17 AC 68 ms
67,200 KB
testcase_18 AC 78 ms
71,168 KB
testcase_19 AC 76 ms
68,864 KB
testcase_20 AC 56 ms
62,464 KB
testcase_21 AC 74 ms
69,248 KB
testcase_22 AC 58 ms
64,512 KB
testcase_23 AC 88 ms
73,472 KB
testcase_24 AC 87 ms
73,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    MOD = 10 ** 9 + 7
    P, K = map(int, rl().split())
    
    dp0 = [0] * (K + 1)
    dp0[0] = 1
    dp1 = [0] * (K + 1)
    for i in range(K):
        dp0[i + 1] = (P + 1) * dp0[i] + 2 * (P - 1) * dp1[i]
        dp0[i + 1] %= MOD
        dp1[i + 1] = dp0[i] + 2 * (P - 1) * dp1[i]
        dp1[i + 1] %= MOD
    print(dp0[K])


if __name__ == '__main__':
    solve()
0