http://codeforces.com/contest/365/problem/B
1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 #define maxn 200010 5 #define LL __int64 6 using namespace std; 7 8 int n; 9 LL a[maxn]; 10 11 int main() 12 { 13 while(scanf("%d",&n)!=EOF) 14 { 15 for(int i=1; i<=n; i++) 16 { 17 scanf("%I64d",&a[i]); 18 } 19 int max1=min(2,n); 20 int len=2; 21 for(int i=3; i<=n; i++) 22 { 23 if(a[i]==a[i-2]+a[i-1]) 24 { 25 len++; 26 max1=max(max1,len); 27 } 28 else len=2; 29 } 30 printf("%d ",max1); 31 } 32 return 0; 33 }