Odd Sum Pair CodeChef Solution

Problem – Odd Sum Pair CodeChef Solution

Chef has 3 numbers A,B and C.

Chef wonders if it is possible to choose exactly two numbers out of the three numbers such that their sum is odd.

Input Format

  • The first line of input will contain a single integer T, denoting the number of test cases.
  • Each test case consists of three integers A,B,C.

Output Format

For each test case, output YES if you can choose exactly two numbers with odd sum, NO otherwise.

The output is case-insensitive. Thus, the strings YESyesyeS, and Yes are all considered the same.

Constraints

  • 1≤T≤100
  • 1≤A,B,C≤10

Sample 1:

Input:
4
1 2 3
8 4 6
3 3 9
7 8 6
Output:
YES
NO
NO
YES

Explanation:

Test case 1: Chef can choose 2 and 3 since 2+3=5 and 5 is odd.

Test case 2: It can be shown that Chef cannot choose two numbers among 8, 4 and 6 with odd sum.

Odd Sum Pair CodeChef Solution in Pyth 3

# cook your dish here
t=int(input())
for i in range(t):
    a,b,c=map(int,input().split())
    if a%2==0 and b%2==0 and c%2==0:
        print("NO")
    elif a%2!=0 and b%2!=0 and c%2!=0:
        print("NO")
    else:
        print("YES")

Odd Sum Pair CodeChef Solution in C++17

#include<bits/stdc++.h>
#define FASTIO_  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long

#define mod 1000000007
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define itr(i,n)    for(ll i=0; i<n; i++)
#define itr_ab(i,a,b)    for(ll i=a; i<=b; i++)
#define itrV(i,n)    for(ll i=0; i<v.size(); i++)
#define fixed cout.setf(ios::fixed);
#define precise cout.precision(15);
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
#define en '\n'

using namespace std;

//use when sorting needed
bool cmp(const pair<ll,ll>&a,const pair<ll,ll>&b)
{
    if(a.se>b.se)
        return 1;
    else
        return 0;
}



int main()
{
    FASTIO_
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll  tc,n,m,x,y,i,j,k;
    string s,t;
    cin>>tc;

    while(tc--)
    {
        ll x,y,z;
        cin>>x>>y>>z;
        ll d=x+y,ok=0;
        if(d%2) ok=1;
        d=z+y;
        if(d%2) ok=1;
         d=x+z;
        if(d%2) ok=1;
        if(ok) yes;
        else no;

    }
    return 0;
}





Odd Sum Pair CodeChef Solution in Java

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc=new Scanner(System.in);
		int q=sc.nextInt();
		while(q!=0)
		{
		    int a=sc.nextInt();
		    int b=sc.nextInt();
		    int v=sc.nextInt();
		   
		    if(((a+b)%2)!=0 || ((b+v)%2)!=0 || ((a+v)%2)!=0)
		    System.out.println("yes");
		    else
		    System.out.println("no");
		    q--;
		    
		}
	}
}
Odd Sum Pair CodeChef Solution Review:

In our experience, we suggest you solve this Odd Sum Pair CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

If you are stuck anywhere between any coding problem, just visit Queslers to get the Odd Sum Pair CodeChef Solution

Find on CodeChef

Conclusion:

I hope this Odd Sum Pair CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

More Coding Solutions >>

LeetCode Solutions

Hacker Rank Solutions

CodeChef Solutions

Leave a Reply

Your email address will not be published. Required fields are marked *