首页 > 其他 > 详细

y^2 = x^3 + 3917 x

时间:2014-03-25 20:45:54      阅读:319      评论:0      收藏:0      [点我收藏+]

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

bubuko.com,布布扣
#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;
        }
    }
}
bubuko.com,布布扣

y^2 = x^3 + 3917 x,布布扣,bubuko.com

y^2 = x^3 + 3917 x

原文:http://www.cnblogs.com/mmqh/p/3622708.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!