#include<iostream>
#include<cmath>
using namespace std;

int main() {
    int k;
    cin >> k;

    int m = 1;
    int n = 1;
    int maxSum = 2;

    for (int i = 1; i <= k; i++) {
        int tempM = i;
        int tempN = i + 1;
        int tempSum = tempM * tempM + tempN * tempN;

        if (pow(tempN * tempN - tempM * tempN - tempM * tempM, 2) == 1 && tempSum > maxSum) {
            m = tempM;
            n = tempN;
            maxSum = tempSum;
        }
    }

    cout << 'm=' << m << endl;
    cout << 'n=' << n << endl;

    return 0;
}
C++ 求解满足特定条件的整数对的最大平方和

原文地址: https://www.cveoy.top/t/topic/iatm 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录