Skip to main content

Command Palette

Search for a command to run...

Educational Codeforces Round 120 (Rated for Div. 2) A Number Problem

Updated
•2 min read•View as Markdown
Educational Codeforces Round 120 (Rated for Div. 2) A Number Problem
A

A Single Programmer Vaiya Who love Code and Food || Undergraduate Student From Daffodil International University.

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.

    Problem Link

So How do you solve this problem?

  1. They gives us 3 sticks and then said that we can break 1 stick into two-part that we can make a rectangle.
  2. 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.
  3. 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;
}

Problem Solving

Part 1 of 1

Problem solving is the core part of our life. In this series i will discuss Implementations, Ad Hoc, Data Structure and Algorithom Based Problem. And share my solving idea with you.

More from this blog

A

anikakash

7 posts

Competitive Programmer | EX BNCC Cadet | Open-Source Enthusiast