Algorithm
problem Link : https://www.codechef.com/problems/PAR2
Problem
Ashu and Arvind participated in a coding contest, as a result of which they received chocolates. Now they want to divide the chocolates between them equally.
Can you help them by deciding if it is possible for them to divide all the chocolates in such a way that they each get an equal number of chocolates?
You cannot break a chocolate in two or more pieces.
Input Format
- The first line of input will contain a single integer , denoting the number of test cases.
- The first and only line of each test case contains a single integer — the number of chocolates they received.
Output Format
For each test case output the answer on a new line — "Yes" (without quotes) if they can divide chocolates between them equally, and "No" (without quotes) otherwise.
Each letter of the output may be printed in either uppercase or lowercase, i.e, "Yes", "YES", and "yEs" will all be treated as equivalent.
Constraints
Sample 1:
4 10 4 3 2
Yes Yes No Yes
Explanation:
Test case : They can divide chocolates such that both of them get chocolates each.
Test case : They can divide chocolates such that both of them get chocolates each.
Test case : There is no way to divide chocolates so that they get equal number of chocolates.
Test case : They can divide chocolates such that both of them get chocolate each.
Code Examples
#1 Code Example with C Programming
Code -
C Programming
#include<stdio.h>
int main()
{
int t,n;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
if(n%2==0) printf("Yes\n");
else printf("No\n");
}
}
Copy The Code &
Try With Live Editor
Input
10
4
3
2
Output
Yes
No
Yes
Demonstration
CodeChef solution PAR2 Parity - PAR2 Parity Codechef solution in C,C++