結果

問題 No.954 Result
ユーザー htensaihtensai
提出日時 2019-12-18 13:14:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 1,216 bytes
コンパイル時間 2,134 ms
コンパイル使用メモリ 74,080 KB
実行使用メモリ 49,732 KB
最終ジャッジ日時 2023-09-17 18:03:32
合計ジャッジ時間 4,792 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,336 KB
testcase_01 AC 41 ms
49,452 KB
testcase_02 AC 42 ms
49,140 KB
testcase_03 AC 41 ms
49,272 KB
testcase_04 AC 41 ms
49,444 KB
testcase_05 AC 45 ms
48,988 KB
testcase_06 AC 43 ms
49,092 KB
testcase_07 AC 43 ms
49,732 KB
testcase_08 AC 42 ms
49,416 KB
testcase_09 AC 43 ms
49,372 KB
testcase_10 AC 42 ms
49,260 KB
testcase_11 AC 41 ms
49,144 KB
testcase_12 AC 43 ms
49,368 KB
testcase_13 AC 42 ms
49,148 KB
testcase_14 AC 42 ms
49,120 KB
testcase_15 AC 42 ms
49,324 KB
testcase_16 AC 41 ms
49,164 KB
testcase_17 AC 42 ms
49,044 KB
testcase_18 AC 41 ms
49,120 KB
testcase_19 AC 40 ms
49,416 KB
testcase_20 AC 41 ms
49,160 KB
testcase_21 AC 43 ms
49,152 KB
testcase_22 AC 41 ms
49,048 KB
testcase_23 AC 42 ms
49,348 KB
testcase_24 AC 41 ms
46,884 KB
testcase_25 AC 42 ms
49,140 KB
testcase_26 AC 42 ms
49,264 KB
testcase_27 AC 43 ms
49,092 KB
testcase_28 AC 42 ms
49,220 KB
testcase_29 AC 41 ms
49,308 KB
testcase_30 AC 42 ms
49,368 KB
testcase_31 AC 41 ms
49,440 KB
testcase_32 AC 43 ms
49,328 KB
testcase_33 AC 42 ms
49,572 KB
testcase_34 AC 42 ms
49,140 KB
testcase_35 AC 43 ms
49,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        long[] arr = new long[5];
        for (int i = 4; i >=0; i--) {
            arr[i] = Long.parseLong(br.readLine());
        }
        if (arr[0] == 1) {
            int count = 1;
            if (arr[1] == 1 || arr[1] == 2) {
                count++;
                for (int i = 2; i < 5; i++) {
                    if (arr[i] == arr[i - 1] + arr[i - 2]) {
                        count++;
                    } else {
                        break;
                    }
                }
            }
            System.out.println(count);
            return;
        }
        int idx = 0;
        int count = 0;
        long prepre = 1;
        long pre = 1;
        while (idx < 5 && pre <= arr[idx]) {
            long now = pre + prepre;
            if (arr[idx] == now) {
                idx++;
                count++;
            } else if (count != 0) {
                break;
            }
            prepre = pre;
            pre = now;
        }
        System.out.println(count);
    }
}
0