# Secret Recipe Codechef Solution

Secret Recipe Codechef Solution: Chef and his competitor Kefa own two restaurants located at a straight road. The position of Chef’s restaurant is X1X1, the position of Kefa’s restaurant is X2X2.

Chef and Kefa found out at the same time that a bottle with a secret recipe is located on the road between their restaurants. The position of the bottle is X3X3.

The cooks immediately started to run to the bottle. Chef runs with speed V1V1, Kefa with speed V2V2.

Your task is to figure out who reaches the bottle first and gets the secret recipe (of course, it is possible that both cooks reach the bottle at the same time).

### Input

• The first line of the input contains a single integer TT denoting the number of test cases. The description of TT test cases follows.
• The first and only line of each test case contains five space-separated integers X1X1, X2X2, X3X3, V1V1 and V2V2.

### Output

For each test case, print a single line containing the string `"Chef"` if Chef reaches the bottle first, `"Kefa"` if Kefa reaches the bottle first or `"Draw"` if Chef and Kefa reach the bottle at the same time (without quotes).

### Constraints

• 1≤T≤1051≤T≤105
• |X1|,|X2|,|X3|≤105|X1|,|X2|,|X3|≤105
• X1<X3<X2X1<X3<X2
• 1≤V1≤1051≤V1≤105
• 1≤V2≤1051≤V2≤105

```3
1 3 2 1 2
1 5 2 1 2
1 5 3 2 2
```

```Kefa
Chef
Draw
```

### Explanation

Example case 1. Chef and Kefa are on the same distance from the bottle, but Kefa has speed 22, while Chef has speed 11.

## Secret Recipe- CodeChef Solution in JAVA

```import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner in=new Scanner(System.in);
int t=in.nextInt();
int x1[]=new int[t];
int x2[]=new int[t];
int x3[]=new int[t];
int v1[]=new int[t];
int v2[]=new int[t];
for(int i=0;i<t;i++)
{
x1[i]=in.nextInt();
x2[i]=in.nextInt();
x3[i]=in.nextInt();
v1[i]=in.nextInt();
v2[i]=in.nextInt();
double d1=Math.abs(x3[i]-x1[i]);
double d2=Math.abs(x3[i]-x2[i]);
double t1=d1/(v1[i]);
double t2=d2/(v2[i]);
if(t1>t2)
System.out.println("Kefa");
else if(t1<t2)
System.out.println("Chef");
else
System.out.println("Draw");
}
}
}
```

## Secret Recipe- CodeChef Solution in CPP

```#include <iostream>
#include <cmath>
using namespace std;
int main() {
long double T, X1, X2, X3, V1, V2, ans1, ans2, d1, d2;
cin >> T;
while(T--) {
cin >> X1 >> X2 >> X3 >> V1 >> V2;
d1 = abs(X1-X3);
d2 = abs(X3-X2);
ans1 = d1/V1;
ans2 = d2/V2;
if(ans1 < ans2) cout << "Chef\n";
else if(ans2 < ans1) cout << "Kefa\n";
else cout << "Draw\n";
}
return 0;
}
```

## Secret Recipe -CodeChef Solution in Python

```t = int(input())
for _ in range(t):
x1,x2,x3,v1,v2 = map(int,input().split())
t1 = (abs(x1-x3))/v1
t2 = (abs(x2-x3))/v2
if t1<t2:
print("Chef")
elif t1==t2:
print("Draw")
else:
print("Kefa")```

Disclaimer: The above Problem(Secret Recipe) is generated by CodeChef but the solution is provided by Chase2learn.com.This tutorial is only for Educational and Learning purpose.

Sharing Is Caring