Algorithm


Problem link: https://www.codechef.com/problems/GDTURN 

Problem

Chef and Chefina are playing with dice. In one turn, both of them roll their dice at once.

They consider a turn to be good if the sum of the numbers on their dice is greater than 6.
Given that in a particular turn Chef and Chefina got  and  on their respective dice, find whether the turn was good.

Input Format

  • The first line of input will contain a single integer , denoting the number of test cases.
  • Each test case contains two space-separated integers  and  — the numbers Chef and Chefina got on their respective dice.

Output Format

For each test case, output on a new line, YES, if the turn was good and NO otherwise.

Each character of the output may be printed in either uppercase or lowercase. That is, the strings NOnonO, and No will be treated as equivalent.

Constraints

  • 1≤�≤100
  • 1≤�,�≤6

Sample 1:

Input
 
Output
 
4
1 4
3 4
4 2
2 6
NO
YES
NO
YES

Explanation:

Test case 1: The sum of numbers on the dice is 1+4=5 which is smaller than 6. Thus, the turn is not good.

Test case 2: The sum of numbers on the dice is 3+4=7 which is greater than 6. Thus, the turn is good.

Test case 3: The sum of numbers on the dice is 4+2=6 which is equal to 6. Thus, the turn is not good.

Test case 4: The sum of numbers on the dice is 2+6=8 which is greater than 6. Thus, the turn is good.

Code Examples

#1 Code Example with C Programming

Code - C Programming

#include<stdio.h>
int main()
{
    int n,x,y;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%d %d",&x,&y);
        if(x+y>6) printf("YES\n");
        else printf("NO\n");
    }
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
4
1 4
3 4
4 2
2 6

Output

x
+
cmd
NO
YES
NO
YES
Advertisements

Demonstration


CodeChef Solution - GDTURN-Good Turn

Previous
CodeChef Solution - Number Mirror - START01
Next
Codechef solution FLOW00 Add Two Numbers in C, C++