PROBLEM LINK:[https://www.codechef.com/problems/EXPCODE2][1]
Author:[https://www.codechef.com/users/vivek96][2]
DIFFICULTY:EASY
PREREQUISITES:Basic Maths,Math Functions
PROBLEM:
Chef want to book Ola Cab,he have to take ride from point one (xi,yi) to second point (xj,yj),Ola cost N rupees per unit, Chef have R rupees in his pocket,
You have to help Chef to find Whether he have suffiecient amount of money in his pocket for paying to ola.
if yes print “yes”(without quotes) else print “no”(without quotes)
EXPLANATION:
From the Question,its clear we have to find distance between two points.
Distance Formula: Given the two points (x1, y1) and (x2, y2), the distance d between these points is given by the:![alt text][3]
find the distance d between 2 points then we know ola cost N rupees per unit so,
total cost=d(distance) ***** N(Cost of Per Unit).
so if total cost<=R(Amount chef have in his pocket) then Print yes else print no
AUTHOR’S AND TESTER’S SOLUTIONS:
class chefandolacab
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int x1=sc.nextInt();
int y1=sc.nextInt();
int x2=sc.nextInt();
int y2=sc.nextInt();
int r=sc.nextInt();
int n=sc.nextInt();
double dist=Math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
if(dist*r<=n)
System.out.println("yes");
else
System.out.println("no");
}
}
Edit-Correction
[1]: https://www.codechef.com/problems/EXPCODE2
[2]: https://www.codechef.com/users/vivek96
[3]: https://discuss.codechef.com/upfiles/dfm.png