Extreme Value Problem
Background
James's journey to mathematics 2.
Description
M and n are known as integers and meet the following two conditions:
① M, 'n ,..., K
② (N ^ 2-mn-m ^ 2) ^ 2 = 1
Compile a program to obtain a group of m and n that meet the preceding two conditions for the given K, and set the maximum value of m ^ 2 + n ^ 2. For example, if K = 1995, then m = 987, n = 1597, then m and n meet the conditions, and the m ^ 2 + n ^ 2 value can be maximized.
Format input format
Enter the value of K in only one row.
Output Format
Output only one line, m ^ 2 + n ^ 2 value.
Example 1 input 1
1995
Sample output 1
3524578
Restrictions
Each test point is 1 second.
Prompt
Source:
Shantou FXOI Group
Phoeagon
ThanX2 Sivon
For TripleY
1 # include <iostream> 2 using namespace std; 3 long int a [10001]; 4 int I = 3; 5 int main () 6 {7 a [1] = 1; 8 a [2] = 1; 9 int k; 10 cin> k; 11 while (a [I-1] <k) 12 {13 a [I] = a [I-1] + a [I-2]; 14 I ++; 15} 16 if (k <= 3) 17 cout <a [I-2] * a [I-2] + a [I-1] * a [I-1]; 18 else19 cout <a [I-2] * a [I-2] + a [I-3] * a [I-3]; 20 return 0; 21}
Fibonacci count !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!