結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー tomo6930tomo6930
提出日時 2021-10-22 23:39:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 197 bytes
コンパイル時間 101 ms
コンパイル使用メモリ 11,740 KB
実行使用メモリ 42,404 KB
最終ジャッジ日時 2023-10-24 15:51:43
合計ジャッジ時間 10,599 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 448 ms
42,324 KB
testcase_01 AC 438 ms
42,324 KB
testcase_02 AC 452 ms
42,324 KB
testcase_03 AC 448 ms
42,324 KB
testcase_04 AC 444 ms
42,324 KB
testcase_05 AC 441 ms
42,324 KB
testcase_06 WA -
testcase_07 AC 447 ms
42,324 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 440 ms
42,324 KB
testcase_13 WA -
testcase_14 AC 458 ms
42,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
N, M = map(int, input().split())

mat = np.matrix([[1, 1], [1, 0]])
fib = np.matrix([[0], [1]])
mat_N = np.linalg.matrix_power(mat, N)
ans = np.dot(mat_N, fib)
print(ans[1, 0]%M)
0