Extreme Value Problem

Source: Internet
Author: User

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 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.