Skip to content

Instantly share code, notes, and snippets.

@mojaie
Created December 5, 2011 07:49
Show Gist options
  • Save mojaie/1432766 to your computer and use it in GitHub Desktop.
Save mojaie/1432766 to your computer and use it in GitHub Desktop.
AOJ0021
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int n = scn.nextInt();
for (int i = 0; i < n; i++) {
double x1 = scn.nextDouble();
double y1 = scn.nextDouble();
double x2 = scn.nextDouble();
double y2 = scn.nextDouble();
double x3 = scn.nextDouble();
double y3 = scn.nextDouble();
double x4 = scn.nextDouble();
double y4 = scn.nextDouble();
if (x2 - x1 == 0 || x4 - x3 == 0) {
if (x2 - x1 == 0 && x4 - x3 == 0) {
System.out.println("YES");
} else {
System.out.println("NO");
}
} else {
double a1 = (y2 - y1) / (x2 - x1);
double a2 = (y4 - y3) / (x4 - x3);
if (a1 == a2) {
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