-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuilding Race october long challange solution
70 lines (60 loc) · 2.9 KB
/
Building Race october long challange solution
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
Problem
Two friends Chef and Chefina are currently on floors AA and BB respectively. They hear an announcement that prizes are being distributed on the ground floor and so decide to reach the ground floor as soon as possible.
Chef can climb down XX floors per minute while Chefina can climb down YY floors per minute. Determine who will reach the ground floor first. In case both reach the ground floor together, print Both.
Input Format
The first line of input will contain a single integer TT, denoting the number of test cases.
The first line of each test case contains four space-separated integers AA, BB, XX, and YY — the current floor of Chef, the current floor of Chefina, speed of Chef and speed of Chefina in floors per minute respectively.
Output Format
For each test case, output on a new line:
Chef if Chef reaches the ground floor first.
Chefina if she reaches the ground floor first.
Both if both reach the ground floor at the same time.
You may print each character of the string in uppercase or lowercase. For example, the strings CHEF, chef, Chef, and chEF are all considered the same.
Constraints
1 \leq T \leq 25001≤T≤2500
1 \leq A, B \leq 1001≤A,B≤100
1 \leq X, Y \leq 101≤X,Y≤10
Sample 1:
Input
Output
4
2 2 2 2
4 2 1 5
3 2 4 1
3 2 2 1
Both
Chefina
Chef
Chef
Explanation:
Test case 11: Chef is on the second floor and has a speed of 22 floors per minute. Thus, Chef takes 11 minute to reach the ground floor. Chefina is on the second floor and and has a speed of 22 floors per minute. Thus, Chefina takes 11 minute to reach the ground floor. Both Chef and Chefina reach the ground floor at the same time.
Test case 22: Chef is on the fourth floor and has a speed of 11 floor per minute. Thus, Chef takes 44 minute to reach the ground floor. Chefina is on the second floor and and has a speed of 55 floors per minute. Thus, Chefina takes 0.40.4 minutes to reach the ground floor. Chefina reaches the ground floor first.
Test case 33: Chef is on the third floor and has a speed of 44 floors per minute. Thus, Chef takes 0.750.75 minutes to reach the ground floor. Chefina is on the second floor and and has a speed of 11 floor per minute. Thus, Chefina takes 22 minutes to reach the ground floor. Chef reaches the ground floor first.
Test case 44: Chef is on the third floor and has a speed of 22 floors per minute. Thus, Chef takes 1.51.5 minutes to reach the ground floor. Chefina is on the second floor and and has a speed of 11 floor per minute. Thus, Chefina takes 22 minutes to reach the ground floor. Chef reaches the ground floor first.
answer:
#include <iostream>
using namespace std;
int main() {
int t;
cin>>t;
while(t--)
{
double a,b,x,y;
cin>>a>>b>>x>>y;
double hi = a/x;
double by = b/y;
if(hi==by)
{
cout<<"Both"<<endl;
}
else if(hi>by)
{
cout<<"Chefina"<<endl;
}
else if(hi<by)
{
cout<<"Chef"<<endl;
}
}
return 0;
}