結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー kuruton456kuruton456
提出日時 2020-12-29 13:18:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 294 bytes
コンパイル時間 87 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 50,640 KB
最終ジャッジ日時 2024-04-15 14:12:21
合計ジャッジ時間 10,852 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 570 ms
49,060 KB
testcase_01 AC 579 ms
43,828 KB
testcase_02 AC 574 ms
43,540 KB
testcase_03 AC 572 ms
43,428 KB
testcase_04 AC 571 ms
43,680 KB
testcase_05 AC 570 ms
43,668 KB
testcase_06 AC 571 ms
43,704 KB
testcase_07 AC 575 ms
43,696 KB
testcase_08 AC 591 ms
43,700 KB
testcase_09 AC 846 ms
43,576 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
N, M = map(int,input().split())
def mat_power(A, M, num):
    result=A
    for j in range(num-1):
        result = result.dot(A)
        result %= M 
    return result
A = np.array([[1,1],[1,0]])
A = mat_power(A, M ,N - 1)
B = np.array([1,0])
C = np.dot(A, B)
print(C[1] % M)
0