There are 4 bars, possibly, having different lengths. Can they be used as the legs of the table, such that:
The legs stay vertically in the vertices of some rectangle;
The surface of the table, possibly, sloping, touches all four legs?
Input
The input contains 4 integers a1, a2, a3, a4 (1≤ai≤109) — the lengths of the bars.
Output
Output “YES” or “NO”, depending on it is possible to make a table with the given design or not.
题解:看矩形对角线桌角和是否相同,如果相同则输出YES,反之输出NO
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int a[5];
for(int i = 0;i<4;i++)
cin>>a[i];
sort(a,a+4);
if((a[0]+a[3])==(a[1]+a[2]))
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
return 0;
}