結果
| 問題 | No.526 フィボナッチ数列の第N項をMで割った余りを求める | 
| コンテスト | |
| ユーザー |  aru_creator | 
| 提出日時 | 2018-11-22 20:47:18 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 423 bytes | 
| コンパイル時間 | 344 ms | 
| コンパイル使用メモリ | 12,544 KB | 
| 実行使用メモリ | 51,028 KB | 
| 最終ジャッジ日時 | 2024-12-24 17:54:29 | 
| 合計ジャッジ時間 | 23,093 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 7 TLE * 5 | 
ソースコード
import numpy as np 
def calFibonatti(N,M):
    if N<=3:
        if N == 1:
            return 0
        return 1
    N = N - 3
    
    
    A = np.zeros((2,2), dtype='int32')
    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 = np.mod(result.dot(A),M)
    
    return result[0][0]
N,M =  map(int, input().split())
print(calFibonatti(N, M))
            
            
            
        