結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー al1ce_nanka189ral1ce_nanka189r
提出日時 2017-06-11 22:58:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 347 bytes
コンパイル時間 76 ms
コンパイル使用メモリ 11,848 KB
実行使用メモリ 14,812 KB
最終ジャッジ日時 2023-10-24 21:24:26
合計ジャッジ時間 4,184 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
14,568 KB
testcase_01 AC 29 ms
10,212 KB
testcase_02 AC 29 ms
10,212 KB
testcase_03 AC 30 ms
10,212 KB
testcase_04 AC 29 ms
10,212 KB
testcase_05 AC 30 ms
10,212 KB
testcase_06 AC 31 ms
10,212 KB
testcase_07 AC 29 ms
10,212 KB
testcase_08 AC 31 ms
10,232 KB
testcase_09 AC 141 ms
10,280 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-

import math

#-------
# Initialize
N,M = map(int, input().split())

#-------
# Define
def fib(n):
    ans, n1, n2 = 1, 0, 1
    if n == 0: return n1
    if n == 1: return n2
    for i in range(2, n):
        ans = n1 + n2
        n1 = n2
        n2 = ans
    return ans

#-------
# Do

#-------
# Output
print(fib(N) % M)
0