-
Notifications
You must be signed in to change notification settings - Fork 0
/
Can Chef
38 lines (35 loc) · 1.39 KB
/
Can Chef
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
Problem
Chef owns a car that can run 15 kilometers using
1 liter of petrol.
He wants to attend a programming camp at DAIICT.
X liters of petrol is present in Chef's car. The distance between his house and DAIICT is Y kilometers.
Determine whether Chef can attend the event and return to his home with the given amount of petrol.
Note: Chef has to return back to home, so the total distance to be covered would be 2⋅Y.
Explanation:
Test case 1: Chef needs to cover a distance of 100 kilometers in total. He can cover it with 10 liters of petrol.
Test case 2: Chef needs to cover a distance of 400 kilometers in total but using 15 liters of petrol, he can cover only 225 kilometers.
Test case 3: Chef needs to cover a distance of 40 kilometers in total. He can cover it with 3 liters of petrol.
/* package codechef; // don't place package name! */
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 sc=new Scanner(System.in);
int t=sc.nextInt();
for(int i=0;i<t;i++){
int x=sc.nextInt(); //petrol
int y=sc.nextInt(); //distance(1l=15km)
int a=x*15;
int b=y*2;
if(a>=b){
System.out.println("yes");
}else{
System.out.println("No");
}
}// your code goes here
}
}