結果

問題 No.954 Result
ユーザー 37zigen
提出日時 2020-03-18 19:00:06
言語 Java
(openjdk 23)
結果
AC  
実行時間 146 ms / 2,000 ms
コード長 839 bytes
コンパイル時間 2,219 ms
コンパイル使用メモリ 77,708 KB
実行使用メモリ 41,616 KB
最終ジャッジ日時 2024-07-04 12:44:23
合計ジャッジ時間 8,445 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 7
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = 5;
		long[] a = new long[n];
		for (int i = 0; i < n; ++i)
			a[i] = sc.nextLong();
		long[] Fib = new long[74];
		Fib[0] = Fib[1] = 1;
		for (int i = 2; i < Fib.length; ++i) {
			Fib[i] = Fib[i - 1] + Fib[i - 2];
		}
		int ans = 0;
		int pos = Arrays.binarySearch(Fib, a[n-1]);
		if(a[n-1]==1&&a[n-2]==1) {
			pos=0;
		}else if(a[n-1]==1) {
			pos=1;
		}
		int p=n-1;
		while (p>=0 && pos >= 0 && Fib[pos] == a[p] && p < a.length) {
			++ans;
			++pos;
			--p;
		}
		System.out.println(ans);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}
0