Three Square
最讨厌模拟题了...
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
struct node
{
int x, y;
friend bool operator <(const node a, const node b)
{
if(a.x != b.x)
return a.x > b.x;
return a.y > b.y;
}
}t[5], tmp;
int sum;
int main()
{
for(int i = 1; i <= 3; i++)
{
cin >> t[i].x >> t[i].y;
if(t[i].x < t[i].y)
swap(t[i].x, t[i].y);
sum += t[i].x * t[i].y;
}
sort(t + 1, t + 4);
int r = sqrt(sum), cnt = 0;
if(r * r == sum)
{
if(t[1].x == r)//最长的边
{
int p = r - t[1].y;
if(t[2].x == t[3].x && t[2].x == r && t[2].y + t[3].y == p) cnt = 1;
if(t[2].x == t[3].x && t[2].x == p && t[2].y + t[3].y == r) cnt = 1;
if(t[2].y == t[3].y && t[2].y == p && t[2].x + t[3].x == r) cnt = 1;
if(t[2].x + t[3].y == r && t[2].y == t[3].x && t[2].y == p) cnt = 1;
}
}
if(cnt)
cout << "YES\n";
else
cout << "NO\n";
return 0;
}

浙公网安备 33010602011771号