#T785. 极值问题
极值问题
Description
Given that m and n are integers satisfying the following two conditions:
</p>① m, n ∈ {1, 2, ..., k}, i.e., 1 ≤ m, n ≤ k
② (n2 - m * n - m2)2 = 1
Your task is: Write a program that takes a positive integer k (1 ≤ k ≤ 109) as input and finds a pair (m, n) that satisfies the above two conditions while maximizing the value of m2 + n2. For example, if the input is k = 1995, the output should be: m=987 n=1597.
Input Format
</strong>A positive integer k (1 ≤ k ≤ 109).
Output Format
Output m and n, following the sample output.
1995
m=987
n=1597
Source
CodesOnline