Three Friends CodeChef Solution - CodingSoln

There are three friends; let's call them A, B, C. They made the following statements:

Problems Code: THREEFR

Contest : PRATICE(SCHOOL)


A: "I have x Rupees more than B."

B: "I have y rupees more than C."

C: "I have z rupees more than A."

You do not know the exact values of x,y,z. Instead, you are given their absolute values, i.e. X=|x|, Y=|y| and Z=|z|. Note that x, y, z may be negative; "having −r rupees more" is the same as "having r rupees less".

CodeChef Solution


Find out if there is some way to assign amounts of money to A, B, C such that all of their statements are true.

Input


The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows. The first and only line of each test case contains three space-separated integers X, Y and Z.


Output

For each test case, print a single line containing the string "yes" if the presented scenario is possible or "no" otherwise (without quotes).


Constraints


1≤T≤1,000 1≤X,Y,Z≤1,000

Subtasks

Subtask #1 (30 points):

1≤T≤30

1≤X,Y,Z≤3

Subtask #2 (70 points): original constraints

Example Input

2

1 2 1

1 1 1


Example Output

yes

no

Explanation

Example 1: One possible way to satisfy all conditions is: A has 10 rupees, B has 9 rupees and C has 11 rupees. Therefore, we have x=1, y=−2, z=1.

 Example 2: There is no way for all conditions to be satisfied.


C++ Solution:

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){

    int t;
    cin>>t;
    while(t--) {

        int x,y,z;
        cin>>x>>y>>z;
        if(x+y+z==2*max(x,max(y,z)))
         cout<<"yes"<<endl;
        else
            cout<<"no"<<endl;


    }
    return 0;
}

C Solution

#include <stdio.h>

int main()
{
	int t;
	scanf("%d",&t);
	for(int i=0;i<t;i++)
	{
	    int x,y,z,m,t;
	    scanf("%d %d %d",&x,&y,&z);
	    t=x+y+z;
	    if(x>y)
	        m=x;
	   else
	        m=y;
	   if(z>m)
	        m=z;
	   if(2*m==t)
	    printf("yes\n");
	   else
	    printf("no\n");
	}
	return 0;
}

Python Solution

for i in range(int(input())):
    X,Y,Z = map(int,input().split())
    if X + Y == Z:
        print("yes")
    elif Y + Z == X:
        print("yes")
    elif X + Z == Y:
        print("yes")
    else:
        print("no")

Disclaimer : The Above Question and Statements  is given By CodeChef.com  and We Only Produce/Write Answer of the Given Problems for Educational Purpose Only. Any Queries Regarding Post Fill the Contact Us Form

Admin

Hi This is the Admin of CodingSoln. Currently Pursuing B. Tech Computer Science and Engineering form KIIT University India

Post a Comment

Previous Post Next Post