結果

問題 No.954 Result
ユーザー tentententen
提出日時 2020-08-25 17:46:36
言語 Java21
(openjdk 21)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 1,040 bytes
コンパイル時間 2,745 ms
コンパイル使用メモリ 74,632 KB
実行使用メモリ 56,460 KB
最終ジャッジ日時 2023-09-17 18:35:04
合計ジャッジ時間 8,792 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
56,436 KB
testcase_01 AC 126 ms
56,048 KB
testcase_02 AC 123 ms
55,772 KB
testcase_03 AC 122 ms
56,040 KB
testcase_04 AC 123 ms
55,812 KB
testcase_05 AC 122 ms
55,832 KB
testcase_06 AC 123 ms
55,644 KB
testcase_07 AC 124 ms
56,272 KB
testcase_08 AC 126 ms
56,060 KB
testcase_09 AC 127 ms
56,108 KB
testcase_10 AC 123 ms
55,908 KB
testcase_11 AC 123 ms
56,400 KB
testcase_12 AC 123 ms
55,884 KB
testcase_13 AC 125 ms
55,840 KB
testcase_14 AC 125 ms
56,088 KB
testcase_15 AC 124 ms
56,460 KB
testcase_16 AC 125 ms
55,932 KB
testcase_17 AC 125 ms
55,856 KB
testcase_18 AC 127 ms
56,004 KB
testcase_19 AC 125 ms
55,760 KB
testcase_20 AC 127 ms
55,944 KB
testcase_21 AC 128 ms
55,968 KB
testcase_22 AC 126 ms
54,240 KB
testcase_23 AC 124 ms
55,884 KB
testcase_24 AC 127 ms
56,160 KB
testcase_25 AC 126 ms
56,060 KB
testcase_26 AC 125 ms
56,184 KB
testcase_27 AC 120 ms
55,760 KB
testcase_28 AC 124 ms
55,860 KB
testcase_29 AC 125 ms
56,460 KB
testcase_30 AC 125 ms
56,132 KB
testcase_31 AC 126 ms
56,368 KB
testcase_32 AC 127 ms
56,052 KB
testcase_33 AC 126 ms
55,832 KB
testcase_34 AC 130 ms
55,856 KB
testcase_35 AC 126 ms
55,708 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    static final int MOD = 1000000007;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long[] arr = new long[5];
        for (int i = 4; i >= 0; i--) {
            arr[i] = sc.nextLong();
        }
        long prepre = 1;
        long pre = 1;
        TreeSet<Long> fibo = new TreeSet<>();
        fibo.add(pre);
        while (pre <= 1000000000000000L) {
            long x = pre + prepre;
            fibo.add(x);
            prepre = pre;
            pre = x;
        }
        int ans = 0;
        if (fibo.contains(arr[0])) {
            ans++;
        } else {
            System.out.println(0);
            return;
        }
        int start = 1;
        if (arr[0] == 1 && arr[1] == 1) {
            start++;
            ans++;
        }
        for (int i = start; i < 5; i++) {
            if (fibo.higher(arr[i - 1]) != arr[i]) {
                break;
            }
            ans++;
        }
        System.out.println(ans);
    }
}
0