#include<iostream> #include<cstdio> using namespace std; int arr[20]; void F(){ arr[0]=0; arr[1]=1; for (int i=2; i<20; i++) arr[i]=arr[i-1]+arr[i-2]; } int FibonacciSearch(int brr[], int n, int low, int high){ F(); int k=0; while (high+1>arr[k]-1){ k++; } for (int i=high; i<arr[k]-1; i++) brr[i]=brr[high]; while (low<=high){ int mid=low+arr[k-1]-1; if (brr[mid]>n){ high=mid-1; k-=1; } else if (brr[mid]<n){ low=mid+1; k-=2; } else{ if (mid<=high) return high; else return high; } } return -1; } int main() { int brr[10], n; for (int i=0; i<5; i++) scanf("%d", &brr[i]); scanf("%d", &n); int k=FibonacciSearch(brr, n, 0, 4); printf("%d", k); return 0; }