y^2 = x^3 + 3917 x

Challenge: find a pair of nonzero integers x and y that obey y^2 = x^3 + 3917 x.

#include <iostream>
#include <cmath>
#include <cstdlib>

using namespace std;

const long long MAX_x=1LL << (21-1); //(x^3 < 2^63-1)
//y^2 = x^3 + 3917 x

int main()
{
    long long x;
    long long y=1;
    cout<<MAX_x<<endl;

    for(x=1;x<MAX_x;x++) {
        for(;y*y<(x*x+3917LL)*x;y++) {}
        if(y*y == (x*x+3917LL)*x) {
            cout<<y<<" "<<x<<endl;
        }
    }
}
原文地址:https://www.cnblogs.com/mmqh/p/3622708.html