結果
問題 | No.954 Result |
ユーザー |
![]() |
提出日時 | 2019-12-18 07:40:39 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 970 bytes |
コンパイル時間 | 145 ms |
コンパイル使用メモリ | 30,464 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-04 12:37:36 |
合計ジャッジ時間 | 1,160 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 7 |
other | AC * 29 |
ソースコード
// 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; }