Skip to content

Instantly share code, notes, and snippets.

@mohitkhosla01
Created October 21, 2016 09:33
Show Gist options
  • Save mohitkhosla01/3f733a0b5342c667b5864c607987e7dd to your computer and use it in GitHub Desktop.
Save mohitkhosla01/3f733a0b5342c667b5864c607987e7dd to your computer and use it in GitHub Desktop.
import java.util.Scanner;
public class kangaroo {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int x1=sc.nextInt();
int v1=sc.nextInt();
int x2=sc.nextInt();
int v2=sc.nextInt();
if((x1>x2 && v1>v2) || (x1<x2 && v1<v2) || (x1!=x2 && v1==v2)|| (x1==x2 && v1!=v2)){
System.out.println("NO");
}
else if(((x1-x2)%(v2-v1))==0){
System.out.println("YES");
}
else{
System.out.println("NO");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment