SHARE
TWEET

codeforce - the fibonacci segment

jakaria_hossain Jun 27th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top