結果

問題 No.954 Result
ユーザー tcltk
提出日時 2021-01-16 09:37:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 152 ms / 2,000 ms
コード長 1,403 bytes
コンパイル時間 260 ms
コンパイル使用メモリ 81,996 KB
実行使用メモリ 89,312 KB
最終ジャッジ日時 2024-11-27 09:24:35
合計ジャッジ時間 7,092 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 7
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#region Header
#!/usr/bin/env python3
# from typing import *

import sys
import io
import math
import collections
import decimal
import itertools
from queue import PriorityQueue
import bisect
import heapq

def input():
    return sys.stdin.readline()[:-1]

sys.setrecursionlimit(1000000)
#endregion

# _INPUT = """233
# 144
# 89
# 55
# 34
# """
# sys.stdin = io.StringIO(_INPUT)


def main():
    a = list(reversed([int(input()) for _ in range(5)]))

    F = [1, 1, 2, 3, 5, 8]
    if a[0] == 1:
        n1 = 5
        for i in range(5):
            if a[i] != F[i]:
                n1 = i
                break
        n2 = 5
        for i in range(5):
            if a[i] != F[1+i]:
                n2 = i
                break
        print(max(n1, n2))

    else:
        k = 2
        while True:
            while len(F) - 1 < k:
                F.append(F[-2] + F[-1])
            if a[0] == F[k]:
                n = 5
                for i in range(5):
                    while len(F) - 1 < k+i:
                        F.append(F[-2] + F[-1])
                    if a[i] != F[k+i]:
                        n = i
                        break
                print(n)
                break
            elif a[0] < F[k]:
                print(0)
                break
            k += 1

if __name__ == '__main__':
    main()
0