-
Notifications
You must be signed in to change notification settings - Fork 0
/
miami Gp(F1RULE) solution
60 lines (47 loc) · 2.38 KB
/
miami Gp(F1RULE) 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
Problem
Chef has finally got the chance of his lifetime to drive in the F1F1 tournament. But, there is one problem. Chef did not know about the 107% rule and now he is worried whether he will be allowed to race in the main event or not.
Given the fastest finish time as XX seconds and Chef's finish time as YY seconds, determine whether Chef will be allowed to race in the main event or not.
Note that, Chef will only be allowed to race if his finish time is within 107% of the fastest finish time.
Input Format
First line will contain TT, number of testcases. Then the testcases follow.
Each testcase contains of a single line of input, two space separated integers XX and YY denoting the fastest finish time and Chef's finish time respectively.
Output Format
For each test case, output \texttt{YES}YES if Chef will be allowed to race in the main event, else output \texttt{NO}NO.
You may print each character of the string in uppercase or lowercase (for example, the strings \texttt{YeS}YeS, \texttt{yEs}yEs, \texttt{yes}yes and \texttt{YES}YES will all be treated as identical).
Constraints
1 \leq T \leq 2\cdot 10^41≤T≤2⋅10
4
1 \leq X \leq Y \leq 2001≤X≤Y≤200
Sample 1:
Input
Output
4
1 2
15 16
15 17
100 107
NO
YES
NO
YES
Explanation:
Test case 11: The fastest car finished in 11 second. Thus, Chef should have finished on or before 1.071.07 seconds to ensure qualification but he finished in 22 seconds. Hence, Chef will not be allowed to race in the main event.
Test case 22: The fastest car finished in 1515 seconds. Thus, Chef should have finished on or before 16.0516.05 seconds to ensure qualification and he managed to finish in 1616 seconds. Hence, Chef will be allowed to race in the main event.
Test case 33: The fastest car finished in 1515 seconds. Thus, Chef should have finished on or before 16.0516.05 seconds to ensure qualification but he finished in 1717 seconds. Hence, Chef will not be allowed to race in the main event.
Test case 44: The fastest car finished in 100100 seconds. Thus, Chef should have finished on or before 107107 seconds to ensure qualification and he finished just in time for qualification. Hence, Chef will be allowed to race in the main event.
answer:
#include <iostream>
using namespace std;
int main() {
int r,m,n;
cin>>r;
for(int i=0;i<r;i++)
{
cin>>m>>n;
if(n<=(m*1.07))
cout<<"yes"<<"\n";
else
cout<<"no"<<"\n";
}
return 0;
}