Gym - 102569K Table
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 a1a1, a2a2, a3a3, a4a4 (1≤ai≤1091≤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.
Examples
Input
1 1 1 1
Output
YES
Input
1 5 1 5
Output
YES
Input
1 3 2 2
Output
YES
Input
9 5 11 8
Output
NO
——————————————————————————————————————————————————————————————————————————————————————————————————————————————
可以斜着碰,从侧面看就是一个梯形,但是另外一边侧面也可以,就是只要中心点重合就不会折。
要么两两相等,要么求对角线相等,就结束了。
#include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <stack> #include <queue> #include <map> #include <vector> #include <set> #include <deque> #include <cfloat> #include <algorithm> typedef long long ll; using namespace std; int gcd(int x,int y) { return y?gcd(y,x%y):x; } int lcm(int x,int y) { return x/gcd(x,y)*y; } int a[5]; int main() { for(int i=0;i<4;i++) { scanf("%d",&a[i]); } sort(a,a+4); if(a[0]==a[1]&&a[2]==a[3]) { printf("YES"); } else if(a[0]+a[3]==a[1]+a[2]) { printf("YES"); } else printf("NO"); }

浙公网安备 33010602011771号