結果

問題 No.303 割れません
ユーザー keikei
提出日時 2018-10-08 19:29:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 467 bytes
コンパイル時間 202 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 44,472 KB
最終ジャッジ日時 2024-04-20 18:44:47
合計ジャッジ時間 12,511 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 506 ms
44,344 KB
testcase_01 AC 506 ms
44,216 KB
testcase_02 AC 512 ms
43,956 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 513 ms
44,100 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 517 ms
43,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np

def pow(A,n):
    B = np.array([[1,0],[0,1]])
    while n > 0:
        if n%2==1:
            B = B.dot(A)
        A = A.dot(A)
        n>>=1
    return B

def fib(L):
    F = np.array([[1,1],[1,0]])
    return pow(F,L-1)[0][0]

def calc(L):
    if L%2==1:
        return fib(L)
    else:
        a = fib(L)
        b = fib(L//2)
        return a - b*b

L=int(input())
if L == 2:
    print(3)
    print("INF")
else:
    print(L)
    print(calc(L))
0