結果
| 問題 |
No.526 フィボナッチ数列の第N項をMで割った余りを求める
|
| コンテスト | |
| ユーザー |
aru_creator
|
| 提出日時 | 2018-11-22 20:32:18 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 396 bytes |
| コンパイル時間 | 107 ms |
| コンパイル使用メモリ | 12,416 KB |
| 実行使用メモリ | 87,920 KB |
| 最終ジャッジ日時 | 2024-12-24 17:53:05 |
| 合計ジャッジ時間 | 21,239 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 4 WA * 4 TLE * 4 |
ソースコード
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='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 = result.dot(A)
return result[0][0]
N,M = map(int, input().split())
print(calFibonatti(N)%M)
aru_creator