P16473 [CodeChef] CAN REACH
普及-
题目描述

A first-year student, came to your college. Being a good senior, you must tell him if it is possible to go from College Main Gate to Hostel for him.

The college can be visualized on a 2D-plane. Suppose the College Main Gate is situated at origin i.e. at the coordinates (0, 0) and the Hostel is situated at the coordinates (x,y).

As the first-year student wants to explore the college campus further, in one move, he will increase or decrease any coordinate (either the x-coordinate or the y-coordinate) by a value of exactly K.

Is it possible for the first-year student to reach the Hostel?

------ Input Format ------

  • First line of input contains a single integer T, denoting the number of test cases. Then the description of the T test case follows.
  • Each test case contains one line of input.
  • The first line contains three integers x, y, K.

------ Output Format ------

For each test case, output a single line answer containing a "YES" or "NO" (without quotes).

You may print each character of each string in uppercase or lowercase (for example, the strings without quotes "yEs", "yes", "Yes" and "YES" will all be treated as identical).

------ Constraints ------

$1 ≤ T ≤ 600$
$-1000 ≤ x, y ≤ 1000$
$1 ≤ K ≤ 1000$

----- Sample Input 1 ------
4
1 2 1
3 -5 2
-9 -6 3
-18 12 5

----- Sample Output 1 ------
YES
NO
YES
NO
----- explanation 1 ------
Test case 1:
Here $K = 1$, One of the paths that the first-year student can follow is described as: $(0, 0)$ to $(1, 0)$ to $(1, 1)$ to $(1, 2)$. Hence, he can reach the hostel coordinate at $(x, y) = (1, 2)$ with the $K = 1$ constraint.

Test case 2:
As here $K = 2$, it can be proved that there is no path to move from $(0, 0)$ to $(3, -5$) by only increasing or decreasing any coordinate by exactly $K = 2$.

Test case 3:
Here $K = 3$, One of the paths that the first-year student can follow is described as: $(0, 0)$ to $(-3, 0)$ to $(-3, -3)$ to $(-3, -6)$ to $(-6, -6)$ to $(-9, -6)$. Hence, he can reach the hostel coordinate at $(x, y) = (-9, -6)$ with the $K = 3$ constraint.

输入格式

见题面

输出格式

见题面

样例输入
4 1 2 1 3 -5 2 -9 -6 3 -18 12 5
样例输出
YES NO YES NO