結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー aru_creatoraru_creator
提出日時 2018-11-22 20:29:40
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 391 bytes
コンパイル時間 84 ms
コンパイル使用メモリ 10,764 KB
実行使用メモリ 34,076 KB
最終ジャッジ日時 2023-08-26 03:59:54
合計ジャッジ時間 6,568 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
34,076 KB
testcase_01 AC 125 ms
29,712 KB
testcase_02 AC 125 ms
29,772 KB
testcase_03 AC 125 ms
29,552 KB
testcase_04 AC 127 ms
29,648 KB
testcase_05 AC 129 ms
29,612 KB
testcase_06 WA -
testcase_07 AC 127 ms
29,576 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np 

def calFibonatti(N):
    if N<=3:
        if N == 1:
            return 0
        return 1
    N = N - 3
    A = np.zeros((2,2),dtype=int)
    A[0][0]=1
    A[0][1]=1
    A[1][0]=1
    A[1][1]=0
    
    result = np.copy(A)
    
    for i in range(N):
        result = result.dot(A)
    
    return result[0][0]

N,M =  map(int, input().split())
print(calFibonatti(N)%M)
0