結果

問題 No.1049 Zero (Exhaust)
ユーザー tcltktcltk
提出日時 2021-01-17 18:43:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 354 ms / 2,000 ms
コード長 777 bytes
コンパイル時間 578 ms
コンパイル使用メモリ 86,784 KB
実行使用メモリ 99,552 KB
最終ジャッジ日時 2023-08-20 01:01:08
合計ジャッジ時間 10,094 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 245 ms
83,028 KB
testcase_01 AC 240 ms
83,208 KB
testcase_02 AC 261 ms
83,184 KB
testcase_03 AC 297 ms
94,216 KB
testcase_04 AC 280 ms
83,192 KB
testcase_05 AC 354 ms
92,212 KB
testcase_06 AC 276 ms
99,296 KB
testcase_07 AC 246 ms
85,456 KB
testcase_08 AC 248 ms
88,192 KB
testcase_09 AC 258 ms
95,376 KB
testcase_10 AC 263 ms
96,140 KB
testcase_11 AC 262 ms
96,416 KB
testcase_12 AC 267 ms
98,408 KB
testcase_13 AC 250 ms
86,804 KB
testcase_14 AC 254 ms
90,452 KB
testcase_15 AC 263 ms
94,676 KB
testcase_16 AC 257 ms
92,016 KB
testcase_17 AC 254 ms
92,592 KB
testcase_18 AC 260 ms
96,672 KB
testcase_19 AC 255 ms
94,232 KB
testcase_20 AC 253 ms
88,192 KB
testcase_21 AC 255 ms
95,000 KB
testcase_22 AC 248 ms
89,476 KB
testcase_23 AC 266 ms
99,552 KB
testcase_24 AC 266 ms
98,976 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#region Header
#!/usr/bin/env python3
# from typing import *

import sys
import io
import math
import collections
import decimal
import itertools
from queue import PriorityQueue
import bisect
import heapq

def input():
    return sys.stdin.readline()[:-1]

sys.setrecursionlimit(1000000)
#endregion

# _INPUT = """# paste here...
# """
# sys.stdin = io.StringIO(_INPUT)

MOD = 1000000007

def main():
    P, K = map(int, input().split())

    dp0 = [0 for _ in range(K+1)]
    dp1 = [0 for _ in range(K+1)]
    dp0[0] = 1
    dp1[0] = 0
    for i in range(K):
        dp0[i+1] = (dp0[i] * (P+1) + dp1[i] * 2) % MOD
        dp1[i+1] = (dp0[i] * (P-1) + dp1[i] * (2*(P-1))) % MOD

    print(dp0[K])

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