下面是ac的代码,第十行改成2* x* x<=a* a就是错的了(91分),x<=y的情况考虑完不应该就可以了吗,不太理解,希望路过的大佬可以帮忙看看www
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int a, b;
cin >> a >> b;
for (int x = 1; x < a; x++)
{
int y = int(sqrt(a * a - x * x) + 0.5);
if (y * y + x * x == a * a)
{
int g = __gcd(x, y);
int v = x / g, u = y / g;
int k = int(sqrt(b * b / (u * u + v * v)) + 0.5);
if (k * k * (u * u + v * v) == b * b)
{
if (x != k * u)
{
cout << "YES\n";
cout << "0 0\n";
cout << x << " " << y << "\n";
cout << k * u << " " << -k * v << "\n";
return 0;
}
}
}
}
cout << "NO\n";
return 0;
}