Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Chef is looking to buy a TV and has shortlisted two models. The first one costs A rupees, while the second one costs B rupees.
Since there is a huge sale coming up on Chefzon, Chef can get a flat discount of C rupees on the first TV, and a flat discount of D rupees on the second one.
Help Chef determine which of the two TVs would be cheaper to buy during the sale.
For each test case, print a single line containing the string First
if the first TV is cheaper to buy with discount, or Second
if the second TV is cheaper to buy with discount. If both of them cost the same after discount, print Any
.
You may print each character of the string in uppercase or lowercase (for example, the strings first
, First
, fIRSt
, and FIRST
will all be treated as identical).
Input: 3
85 75 35 20
100 99 0 0
30 40 0 10
Output: First
Second
Any
Test case 1: The cost of the first TV after discount is 85−35=50, while the cost of the second TV after discount is 75−20=55. Thus the first TV is cheaper to buy than the second.
Test case 2: The cost of the first TV after discount is 100−0=100, while the cost of the second TV after discount is 99−0=99. Thus the second TV is cheaper to buy than the first.
Test case 3: The cost of the first TV after discount is 30−0=30, while the cost of the second TV after discount is 40−10=30. Since they are equal, Chef can buy any of them.
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main()
{
int t;
cin>>t;
while(t--)
{
int x,y,z,w;
cin>>x>>y>>z>>w;
x-=z;
y-=w;
if(x==y)
cout<<"Any\n";
else if(x>y)
cout<<"Second\n";
else
cout<<"First\n";
}
}
import java.util.*;
import java.lang.*;
import java.io.*;
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
for(int i=0; i<t; i++){
int a=sc.nextInt();
int b=sc.nextInt();
int c=sc.nextInt();
int d=sc.nextInt();
if((a-c)<(b-d)){
System.out.println("First");
}else if((a-c)>(b-d)){
System.out.println("Second");
}else{
System.out.println("Any");
}
}
}
}
t=int(input())
for i in range(t):
a,b,c,d=map(int,input().split())
if a-c>b-d:
print("second")
elif a-c==b-d:
print("any")
else:
print("first")
In our experience, we suggest you solve this TV Discount CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
If you are stuck anywhere between any coding problem, just visit Queslers to get the TV Discount CodeChef Solution
I hope this TV Discount CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.
This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.
Keep Learning!
More Coding Solutions >>