Help me in solving PIXDAM problem

My issue

The problem statement mentions the distance of point P must be calculated from the BOTTOM-RIGHT corner, but it seems the solutions are for top-right.

My code

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;
import static java.lang.Math.*;

/* 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();
		 
		while (T-- > 0) {
		    int h = sc.nextInt();
		    int w = sc.nextInt();
		    int x = sc.nextInt();
		    int y = sc.nextInt();
		    int k = sc.nextInt();
		    int distance = (int) sqrt(
		        (pow(x - w, 2)) 
		        + (pow(y - h, 2)));
		    System.out.println(distance < k ? 1 : 0);
		}
	}
}

Problem Link: CodeChef: Practical coding for everyone

1 Like

@abhhello_world
U have to do it like this

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
	{
		// your code goes here
		Scanner sc= new Scanner(System.in);
		int t=sc.nextInt();
		for(int i=0;i<t;i++){
		      long  h=sc.nextInt(); //dimensions  height and width
		      long  w=sc.nextInt();
		 
		      long  x=sc.nextInt();
		      long  y=sc.nextInt();
		      long  k=sc.nextInt();
		 
		     double  res =  Math.sqrt((h-y)*(h-y) + (w-x)*(w-x));

		     if(res<k){
		     System.out.println("1");
	    	 }
		     else{
		     System.out.println("0");
		 }
	}
}
}