結果

問題 No.954 Result
コンテスト
ユーザー えりす
提出日時 2026-06-06 20:20:13
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 698 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,430 ms
コンパイル使用メモリ 84,608 KB
実行使用メモリ 52,224 KB
最終ジャッジ日時 2026-06-06 20:20:17
合計ジャッジ時間 3,148 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
純コード判定待ち
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 7
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
def solve():
    a = [int(sys.stdin.readline()) for _ in range(5)]
    f = [1, 1]
    while f[-1] + f[-2] <= 10 ** 15:
        f.append(f[-1] + f[-2])
    s = set(f)
    ok_pair = set()
    for i in range(len(f) - 1):
        ok_pair.add((f[i], f[i + 1]))
    for n in range(5, 0, -1):
        ok = 1
        if n == 1:
            if a[4] not in s:
                ok = 0
        else:
            for i in range(n - 1):
                x = a[4 - i]
                y = a[4 - i - 1]
                if (x, y) not in ok_pair:
                    ok = 0
                    break
        if ok:
            print(n)
            return
    print(0)

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