#P2520. [HAOI2011] 向量

    ID: 1535 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>数学2011河南各省省选最大公约数,gcd向量

[HAOI2011] 向量

Description

Given a pair of numbers (a,b)(a,b), you may use any of the vectors (a,b)(a,b), (a,b)(a,-b), (a,b)(-a,b), (a,b)(-a,-b), (b,a)(b,a), (b,a)(b,-a), (b,a)(-b,a), (b,a)(-b,-a) in arbitrary quantities. Determine whether you can form another vector (x,y)(x,y).

Note: Here, “form” means that the sum of the vectors you choose equals (x,y)(x,y).

Input Format

The first line contains the number of test cases tt (t50000t \le 50000).

The next tt lines each contain four integers a,b,x,ya, b, x, y (2×109a,b,x,y2×109-2\times 10^9 \le a, b, x, y \le 2\times 10^9).

Output Format

Output tt lines. Each line is Y if it is possible, or N if it is not.

3
2 1 3 3
1 1 0 1
1 0 -2 3
Y
N
Y

Hint

Sample Explanation

Group 1: (2,1)+(1,2)=(3,3)(2,1) + (1,2) = (3,3).

Group 3: (1,0)+(1,0)+(0,1)+(0,1)+(0,1)=(2,3)(-1,0) + (-1,0) + (0,1) + (0,1) + (0,1) = (-2,3).

Translated by ChatGPT 5