Editorial-Chocolate Milkshake Recipe |Encoding February 22

PROBLEM LINK :

Practice
Contest Link
Problem Link

Author: Srinjoy Pal
Tester: Abhisekh Paul ,Sayan Poddar
Editorialist: Srinjoy Pal

DIFFICULTY:

CAKEWALK

PREREQUISITES:

Conditional Statements

PROBLEM:

Checking if all the inputs are following all the required conditions according to the question.

EXPLANATION:

Checking all the required conditions using AND operator since all the conditions need to be TRUE .

TIME COMPLEXITY:

O(1)

SPACE COMPLEXITY:

O(1)

SOLUTION:

Setter's Solution: C++
#include <bits/stdc++.h>
using namespace std;
int main(){
ll t;
cin>>t;
while(t--)
{
   int m,c,i,s;
   cin>>m>>c>>i>>s;
   if(c==m/2 && i==3*c && s<(i/2) && s>c)
   cout<<"YES"<<endl;
   else
   cout<<"NO"<<endl;
 }
return 0;
}
Tester's Solution: Python
for _ in range(int(input())):
a,x,c,d=list(map(int, input().split()))
if a==2*x and c==3*x and x<d<1.5*x:
    print("yes")
else:
    print("no")
Tester's Solution: Java
import java.util.*;
class Sept1
{
public static void  main (String[] args) {
    Scanner sc=new Scanner(System.in);
    int t=Integer.parseInt(sc.nextLine());
    while(t>0)
    {
        String s[]=sc.nextLine().split(" ");
       int m=Integer.parseInt(s[0]);
        int c=Integer.parseInt(s[1]);
        int ice=Integer.parseInt(s[2]);
        int sug=Integer.parseInt(s[3]);
       if(c==m/2)
       {
           if(ice==3*c)
           {
               if(sug<ice/2 && sug>c)
               {
               System.out.println("Yes");
               t--;
               continue;
                   
               }
           }
       }
        System.out.println("No");
        t--;
            
    }
}
}