Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Alice and Bob are very good friends and they always distribute all the eatables equally among themselves.
Alice has A chocolates and Bob has B chocolates. Determine whether Alice and Bob can distribute all the chocolates equally among themselves.
Note that:
For each test case, output on a new line \texttt{YES}YES if Alice and Bob can distribute all the chocolates equally, else output \texttt{NO}NO. The output is case insensitive, i.e, \texttt{yes}yes, \texttt{YeS}YeS, \texttt{yES}yES will all be accepted as correct answers when Alice and Bob can distribute the chocolates equally.
Input: 4
1 1
1 3
1 2
1 4
Output: YES
YES
NO
NO
Test case 1: Both Alice and Bob already have equal number of chocolates, hence it is possible to distribute the chocolates equally among Alice and Bob.
Test case 2: If Bob gives one of his chocolates to Alice, then both of them will have equal number of chocolates, i.e. 2. So, it is possible to distribute the chocolates equally among Alice and Bob.
Test case 3: There are total 3 chocolates. These chocolates cannot be divided equally among Alice and Bob.
Test case 4: Alice and Bob cannot have equal number of chocolates, no matter how they distribute the chocolates.
import java.util.*;
import java.lang.*;
import java.io.*;
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
int a=sc.nextInt();
int b=sc.nextInt();
if(b%2!=0&&a%2!=0||b%2==0&&a%2==0){
System.out.println("yes");
}else{
System.out.println("No");
}
}
}
}
for _ in range(int(input())):
a,b = map(int,input().split())
t = a + b
if t%2 == 0:
print('Yes')
else:
print('No')
#include <iostream>
using namespace std;
int main() {
int t;
cin>>t;
while(t--){
int a,b;
cin>>a>>b;
int ans=a+b;
if(ans%2==0){
cout << "Yes" <<endl;
}
else{
cout <<"No" <<endl;
}
}
return 0;
}
In our experience, we suggest you solve this Equal Distribution 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 Equal Distribution CodeChef Solution
I hope this Equal Distribution 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 >>