JDCC '15 Contest 5 P1 - Multiples

View as PDF

Submit solution

Points: 3
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

Two points (x_1, y_1) and (x_2, y_2) are said to be integer multiples if there is an integer N such that (x_1, y_1) = (N \times x_2, N \times y_2) or (N \times x_1, N \times y_1) = (x_2, y_2). For example,

  • (1, 2) and (2, 4) are integer multiples, since for N = 2, (2 \times 1, 2 \times 2) = (2, 4)
  • (1, 2) and (-3, -6) are also integer multiples (N = -3)
  • (1, 2) and (1, 3) are not integer multiples, since there is no N such that (N \times 1, N \times 2) = (1, 3) and vice versa.

Given two points, figure out if they are integer multiples of each other.

Input Specification

The first line of input provides the number of test cases, T (1 \le T \le 100). T test cases follow. Each test case consists of two lines. Each line contains two integers x, y, which represent a point (x, y).

Output Specification

For each test case, your program should output one line containing YES if the two points are integer multiples, or NO otherwise.

Sample Input

4
1 2
-4 -8
3 7
9 21
26 2
13 1
0 7
1 7

Sample Output

YES
YES
YES
NO

Explanation for Sample

Looking at the first three test cases in order, we note that:

  • (-4 \times 1, -4 \times 2) = (-4, -8)
  • (3 \times 3, 3 \times 7) = (9, 21)
  • (26, 2) = (2 \times 13, 2 \times 1)

Comments

There are no comments at the moment.