Educational Codeforces Round 120 (Rated for Div. 2) A Number Problem.
This Problem is taken from Code Forces.
They give you 3 sticks which are integer. And then ask you to make a Rectangle with those 3 sticks. But They said that you can break any of one stick. But there are a few conditions.
- both pieces have positive (strictly greater than 0) integer length.
- the total length of the pieces is equal to the original length of the stick.
it's possible to construct a rectangle from the resulting four sticks such that each stick is used as exactly one of its sides.
So How do you solve this problem?
- They gives us 3 sticks and then said that we can break 1 stick into two-part that we can make a rectangle.
- If any of the stick sum is equal to another part then we can make it. Because we can break the other part in equal size.
- If any two-part is equal and another one is even then also we can make the rectangle.
Otherwise, we can't make any rectangle with our given input.
Input
4
6 1 5
2 5 2
2 4 2
5 5 4
Output
YES
NO
YES
YES
Code
#include<bits/stdc++.h>
using namespace std;
int main() {
int tt; cin>>tt;
while(tt--){
int a,b,c;cin>>a>>b>>c;
if((a+b == c)||(a+c==b)||(b+c==a))cout<<"YES"<<endl;
else if(((a==b) && (c%2==0)) || ((b==c) && (a%2==0)) || ((a==c) && (b%2==0)))cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}