結果

問題 No.44 DPなすごろく
ユーザー kaoru murata
提出日時 2021-08-28 12:14:32
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 31 ms / 5,000 ms
コード長 483 bytes
コンパイル時間 136 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-11-21 20:53:56
合計ジャッジ時間 1,614 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

def read_int(): return int(input())
def read_int_list(): return list(map(int, input().split()))


def fast_doubling(i):
    if i == 0:
        return 0, 1
    elif i == 1:
        return 1, 1
    else:
        a, b = fast_doubling(i >> 1)
        if i & 1:
            return a * a + b * b, b * (2 * a + b)
        else:
            return a * (2 * b - a), a * a + b * b


def fibonacci_number(i):
    _, ret = fast_doubling(i)
    return ret


print(fibonacci_number((read_int())))
0