結果

問題 No.954 Result
ユーザー bal4ubal4u
提出日時 2019-12-18 07:40:39
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 970 bytes
コンパイル時間 381 ms
コンパイル使用メモリ 28,980 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-17 18:03:21
合計ジャッジ時間 1,737 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 0 ms
4,380 KB
testcase_05 AC 0 ms
4,376 KB
testcase_06 AC 0 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 0 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 0 ms
4,380 KB
testcase_13 AC 0 ms
4,376 KB
testcase_14 AC 0 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 0 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 0 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 0 ms
4,380 KB
testcase_22 AC 0 ms
4,380 KB
testcase_23 AC 0 ms
4,376 KB
testcase_24 AC 0 ms
4,376 KB
testcase_25 AC 0 ms
4,380 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 0 ms
4,376 KB
testcase_29 AC 0 ms
4,380 KB
testcase_30 AC 0 ms
4,376 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 0 ms
4,376 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 0 ms
4,380 KB
testcase_35 AC 0 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// yuki 954 Result
// 2019.12.18 bal4u

#include <stdio.h>

typedef long long ll;

int getchar_unlocked(void);
#define gc() getchar_unlocked()

ll in() {   // 非負整数の入力
	ll n = 0;
	int c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

#define MAX 73 // f[73]=1304969544928657
ll f[MAX+5]; // f[0]=1, f[1]=1, f[2]=2, f[3]=3

void fibonacci(int a0, int a1) {
	int i;
	f[0] = a0, f[1] = a1;
	for (i = 2; i <= MAX; ++i) f[i] = f[i-2]+f[i-1];
}

int bsch(ll x) {
	int m, l = 0, r = MAX;
    while (l < r) {
        m = (l + r) >> 1;
		if (f[m] == x) return m;
        if (f[m] < x) l = m + 1; else r = m;
    }
	return f[l] == x? l: -1;
}

int main()
{
	int i, j;
	ll a[5];
	
	fibonacci(1, 1);
	for (i = 4; i >= 0; --i) a[i] = in();
	i = 0;
	if (a[0] == 1) {
		j = 1;
		if (a[1] == 1) i = 1;
	} else if ((j = bsch(a[0])) < 0) { puts("0"); return 0; }
	while (++i < 5) {
		if (a[i] != f[++j]) break;
	}
	printf("%d\n", i);
	return 0;
}
0