We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int x1 = in.nextInt();
int v1 = in.nextInt();
int x2 = in.nextInt();
int v2 = in.nextInt();
int a = x1 - x2;
int b = v1 - v2;
String res = "NO";
if(a*b < 0 && a%b == 0){
res = "YES";
}
System.out.println(res);
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Number Line Jumps
You are viewing a single comment's thread. Return to all comments →
public static void main(String[] args) { Scanner in = new Scanner(System.in); int x1 = in.nextInt(); int v1 = in.nextInt(); int x2 = in.nextInt(); int v2 = in.nextInt(); int a = x1 - x2; int b = v1 - v2; String res = "NO"; if(a*b < 0 && a%b == 0){ res = "YES"; } System.out.println(res); }