Algorithm


 problem Link :  https://www.codechef.com/problems/AVGPROBLEM 

Problem

You are given 3 numbers �,�, and .

Determine whether the average of  and  is strictly greater than  or not?

NOTE: Average of  and  is defined as (�+�)2. For example, average of 5 and 9 is 7, average of 5 and 8 is 6.5.

Input Format

  • The first line of input will contain a single integer , denoting the number of test cases.
  • Each test case consists of 3 integers �,�, and .

Output Format

For each test case, output YES if average of  and  is strictly greater than NO otherwise.

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

Constraints

  • 1≤�≤1000
  • 1≤�,�,�≤10

Sample 1:

Input
 
Output
 
5
5 9 6
5 8 6
5 7 6
4 9 8
3 7 2
YES
YES
NO
NO
YES

Explanation:

Test case 1: The average value of 5 and 9 is 7 which is strictly greater than 6.

Test case 2: The average value of 5 and 8 is 6.5 which is strictly greater than 6.

Test case 3: The average value of 5 and 7 is 6 which is not strictly greater than 6.

Test case 4: The average value of 4 and 9 is 6.5 which is not strictly greater than 8.

Test case 5: The average value of 3 and 7 is 5 which is strictly greater than 2.

Code Examples

#1 Code Example with C Programming

Code - C Programming

 #include<stdio.h>
int main()
{
    int t,a,b,c;
    float avg;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d %d %d",&a,&b,&c);
        avg=(a+b)/2.0;
        if(avg>c) printf("YES\n");
        else printf("NO\n");
    }
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
5
5 9 6
5 8 6
5 7 6
4 9 8
3 7 2

Output

x
+
cmd
YES
YES
NO
NO
YES
Advertisements

Demonstration


CodeChef solution AVGPROBLEM Greater Average CodeChef solution in  C,C++

Previous
CodeChef solution in INCRIQ - Increase IQ Codechef solution in C,C++
Next
CodeChef solution CRICMATCH - Cricket Match Codechef solution in C,C++