
ZOJ Problem Set  2672
A sequence of integer numbers a_{1} , a_{2} , ..., a_{n} is called a Fibonacci sequence if a_{i} = a_{i2}+a_{i1} for all i=3,4,...,n. Given a sequence of integer numbers c_{1} , c_{2} , ..., c_{m} you have to find its longest Fibonacci subsequence. InputThere are several test cases in the input. The first line of each case contains m (1 <= m <= 3,000). Next line contains m integer numbers not exceeding 10^{9} by their absolute value.There is a new line between each case. OutputOn the first line of each case print the maximal length of the Fibonacci subsequence of the given sequence. On the second line print the subsequence itself.There is a new line between each case. Example
Source: Andrew Stankevich's Contest #8 