#JSUTFPC2025K. Rabbit Sequence —— 兔子序列
Rabbit Sequence —— 兔子序列
Statement
The rabbit sequence, also known as the Fibonacci sequence, is a sequence of length denoted as if and only if it satisfies one of the following conditions:
- or ;
- When , satisfies .
Given an array consisting of positive integers, find the length of the longest consecutive rabbit subsequence of the array [1].
Input
The first line contains an integer representing the length of the sequence; where satisfies
The second line contains integers representing the number of occurrences of each number in the array; each number satisfies .
Output
Output an integer representing the length of the longest consecutive rabbit subsequence of .
Samples
8
1 1 1 1 2 3 5 1
5
5
5 2 7 9 16
5
Notes
对于第一组样例最长的连续兔子子序列是 ,长度为 5。
对于第二组样例最长的连续兔子子序列是 ,长度为 5。
A sequence is a consecutive rabbit subsequence of another sequence if and only if there exists an interval such that is exactly equal to a subsequence of within that interval and is a rabbit sequence. ↩︎