結果

問題 No.1049 Zero (Exhaust)
ユーザー ああいいああいい
提出日時 2021-12-05 19:28:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 526 bytes
コンパイル時間 126 ms
コンパイル使用メモリ 10,920 KB
実行使用メモリ 7,992 KB
最終ジャッジ日時 2023-09-21 14:55:01
合計ジャッジ時間 1,508 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,808 KB
testcase_01 AC 15 ms
7,868 KB
testcase_02 AC 15 ms
7,728 KB
testcase_03 AC 15 ms
7,932 KB
testcase_04 AC 15 ms
7,880 KB
testcase_05 AC 15 ms
7,860 KB
testcase_06 AC 15 ms
7,808 KB
testcase_07 AC 16 ms
7,816 KB
testcase_08 AC 16 ms
7,864 KB
testcase_09 AC 15 ms
7,800 KB
testcase_10 AC 16 ms
7,860 KB
testcase_11 AC 15 ms
7,868 KB
testcase_12 AC 15 ms
7,812 KB
testcase_13 AC 15 ms
7,800 KB
testcase_14 AC 15 ms
7,932 KB
testcase_15 AC 15 ms
7,992 KB
testcase_16 AC 16 ms
7,816 KB
testcase_17 AC 15 ms
7,860 KB
testcase_18 AC 16 ms
7,864 KB
testcase_19 AC 15 ms
7,812 KB
testcase_20 AC 15 ms
7,936 KB
testcase_21 AC 16 ms
7,860 KB
testcase_22 AC 15 ms
7,732 KB
testcase_23 AC 15 ms
7,860 KB
testcase_24 AC 15 ms
7,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

P,K = list(map(int,input().split()))

p = 10 ** 9 + 7

def multi(l,m):
    a,b = l[0]
    c,d = l[1]
    x,y = m[0]
    z,w = m[1]
    return [[(a * x + b * z) % p,(a * y + b * w) % p],
            [(c * x + d * z) % p,(c * y + d * w) % p]]

A = [[P+1,2],[P-1,2 * P - 2]]
c = 1
while 2 ** c <= K:
    c += 1
Mat = [0] * (c + 1)
Mat[0] = [[1,0],[0,1]]
Mat[1] = A
for i in range(2,c + 1):
    Mat[i] = multi(Mat[i-1],Mat[i-1])
E = Mat[0]
for i in range(0,c+1):
    if K & (1 << i):
        E = multi(E,Mat[i+1])
print(E[0][0])
0