結果

問題 No.1049 Zero (Exhaust)
ユーザー tcltktcltk
提出日時 2021-01-17 19:04:38
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,049 bytes
コンパイル時間 463 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 89,600 KB
最終ジャッジ日時 2024-05-07 08:54:21
合計ジャッジ時間 4,942 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
権限があれば一括ダウンロードができます

ソースコード

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
import numpy as np


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

sys.setrecursionlimit(1000000)
#endregion

# _INPUT = """5 10
# """
# sys.stdin = io.StringIO(_INPUT)

MOD = 1000000007

def main():
    P, K = map(int, input().split())
    
    A = np.matrix([[P+1, 2], [P-1, 2*P-2]])
    M = A
    An = np.identity(M.shape[0], dtype=object)
    while K > 0:
        if K & 1 > 0:
            An = An * M % MOD
        M = M * M % MOD
        K >>= 1
    print(An[0, 0])

    # 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