Chef and Quadilateral Solution

Problem

Chef have given the sizes of angles of a simple quadrilateral (in degrees) ABC and D, in some order along its perimeter. Determine whether the quadrilateral is cyclic.

Note: A quadrilateral is cyclic if and only if the sum of opposite angles is 180^{\circ}.

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 four space-separated integers ABC and D.

Output

Print a single line containing the string "YES" if the given quadrilateral is cyclic or "NO" if it is not (without quotes).

You may print each character of the string in uppercase or lowercase (for example, the strings "yEs", "yes", "Yes" and "YES" will all be treated as identical).

Constraints

  • 1 \leq T \leq 10^4
  • 1 \leq A, B, C, D \leq 357
  • A + B + C + D = 360

Example Input

3
10 20 30 300
10 20 170 160
179 1 179 1

Example Output

NO
YES
NO

Explanation

Example case 1: The sum of two opposite angles A + C = 10^{\circ} + 30^{\circ} \neq 180^{\circ}.

Example case 2: The sum of two opposite angles A + C = 10^{\circ} + 170^{\circ} = 180^{\circ} and B + D = 20^{\circ} + 160^{\circ} = 180^{\circ}.

Example case 3: The sum of two opposite angles B + D = 1^{\circ} + 1^{\circ} \neq 180^{\circ}.




Program :

 #include<stdio.h>

int main()

{

     int A,B,C,D, i ,T;

      scanf("%d\n", &T);

    for(i=1;i<=T;i++){

        scanf("%d %d %d %d",&A,&B,&C,&D);

        if(A+C==180)

        {

            printf("YES\n");

        }

        else

        {

            printf("NO\n");

        }

    }

    return  0;

}


Post a Comment

0 Comments