結果

問題 No.303 割れません
ユーザー maspymaspy
提出日時 2020-04-10 14:32:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 501 bytes
コンパイル時間 1,427 ms
コンパイル使用メモリ 10,820 KB
実行使用メモリ 10,500 KB
最終ジャッジ日時 2023-10-13 04:02:46
合計ジャッジ時間 7,892 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,760 KB
testcase_01 AC 16 ms
7,756 KB
testcase_02 AC 17 ms
7,844 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 16 ms
8,184 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 15 ms
8,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 10
L = int(read())

if L == 2:
    print(3)
    print('INF')
    exit()


def fibonacci(n):
    # x^n = a + bx mod x^2-x-1
    if n == 0:
        return 1, 0
    a, b = fibonacci(n // 2)
    c = b * b
    a, b = a * a + c, 2 * a * b + c
    return (b, a + b) if n & 1 else (a, b)


_, x = fibonacci(L)
if L % 2 == 0:
    _, y = fibonacci(L // 2)
    x -= y * y
print(L)
print(x)
0