Created
January 6, 2014 04:59
-
-
Save codyhan94/8278493 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int array[]; | |
int prev2 = array[0]; | |
int prev1 = array[1]; | |
int sum_prev = prev1 + prev2; | |
bool seg_good = true; | |
for (int i = 2; i < n; ++i) | |
{ | |
int cur = array[i]; | |
if (cur == sum_prev) | |
{ | |
longest_seg++; | |
} | |
else | |
{ | |
longest_seg = 2; | |
} | |
prev2 = prev1; | |
prev1 = cur; | |
sum_prev = prev1 + prev2; | |
} | |
cout << longest_seg << endl; | |
return 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment