Advertisement
jakaria_hossain

codeforce - the fibonacci segment

Jun 27th, 2019
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. #define fast()(ios_base::sync_with_stdio(false),cin.tie(NULL));
  5. int main()
  6. {
  7. fast();
  8. ll n,m=0,x=2,i;
  9. cin>>n;
  10. ll ara[n+1];
  11. for(i=0;i<n;i++)cin>>ara[i];
  12. for(i=2;i<n;i++)
  13. {
  14. if(ara[i-1]+ara[i-2]==ara[i])x++;
  15. else
  16. {
  17. m=max(m,x);
  18. x=2;
  19. }
  20. }
  21. m=max(m,x);
  22. if(n<=2)m=n;
  23. cout<<m<<endl;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement