1624B. Make AP

1624B. Make AP

1624B. Make AP

  • time limit per test2 seconds
  • memory limit per test256 megabytes
  • inputstandard input
  • outputstandard output

Polycarp has 3 positive integers a, b and c. He can perform the following operation exactly once.

Polycarp有3个正整数a、b和c。他可以只执行一次以下操作。

Choose a positive integer m and multiply exactly one of the integers a, b or c by m.

选择一个正整数m,将a、b或c中的一个整数正好乘以m。

Can Polycarp make it so that after performing the operation, the sequence of three numbers a, b, c (in this order) forms an arithmetic progression? Note that you cannot change the order of a, b and c.

Polycarp是否可以使三个数字a、b、c(按此顺序)的序列在执行运算后形成算术级数?请注意,不能更改a、b和c的顺序。

Formally, a sequence x1_1,x2_2,…,xn_n is called an arithmetic progression (AP) if there exists a number d (called "common difference") such that xi+1_{i+1}=xi_i+d for all i from 1 to n−1. In this problem, n=3.

形式上,如果存在一个数字d(称为“公共差”),那么序列x1_1,x2_2,…,xn_n被称为算术级数(AP),使得从1到n的所有i的xi+1_{i+1}=xi_i+d.在这个问题中,n=3。

For example, the following sequences are AP: [5,10,15], [3,2,1], [1,1,1], and [13,10,7]. The following sequences are not AP: [1,2,4], [0,1,0] and [1,3,2].

例如,以下序列是AP:[5,10,15]、[3,2,1]、[1,1,1]和[13,10,7]。以下序列不是AP:[1,2,4]、[0,1,0]和[1,3,2]。

You need to answer t independent test cases.

你需要回答t个独立的测试用例。

Input

The first line contains the number t (1≤t≤104^4) — the number of test cases.

第一行包含数字t(1≤T≤104^4)-测试用例的数量。

Each of the following t lines contains 3 integers a, b, c (1≤a,b,c≤108^8).

以下每一条t线都包含3个整数a、b、c(1≤a、 b,c≤108^8).

Output

For each test case print "YES" (without quotes) if Polycarp can choose a positive integer m and multiply exactly one of the integers a, b or c by m to make [a,b,c] be an arithmetic progression. Print "NO" (without quotes) otherwise.

对于每个测试用例,如果Polycarp可以选择一个正整数m,并将其中一个整数a、b或c乘以m,则打印“是”(不带引号),使[a、b、c]成为算术级数。否则打印“否”(不带引号)。

You can print YES and NO in any (upper or lower) case (for example, the strings yEs, yes, Yes and YES will be recognized as a positive answer).

您可以以任何(大写或小写)形式打印是和否(例如,字符串YES、YES、YES和YES将被识别为肯定答案)。

Example
input
11
10 5 30
30 5 10
1 2 3
1 6 3
2 6 3
1 1 1
1 1 2
1 1 3
1 100000000 1
2 1 1
1 2 2
output
YES
YES
YES
YES
NO
YES
NO
YES
YES
NO
YES
Note

In the first and second test cases, you can choose the number m=4 and multiply the second number (b=5) by 4.

在第一个和第二个测试用例中,您可以选择数字m=4,并将第二个数字(b=5)乘以4。

In the first test case the resulting sequence will be [10,20,30]. This is an AP with a difference d=10.

在第一个测试用例中,结果序列将为[10,20,30]。这是一个差值为d=10的AP。

In the second test case the resulting sequence will be [30,20,10]. This is an AP with a difference d=−10.

在第二个测试用例中,结果序列将为[30,20,10]。这是一个不同于d的AP=−10

In the third test case, you can choose m=1 and multiply any number by 1. The resulting sequence will be [1,2,3]. This is an AP with a difference d=1.

在第三个测试用例中,您可以选择m=1并将任意数字乘以1。结果序列将为[1,2,3]。这是一个差值为d=1的AP。

In the fourth test case, you can choose m=9 and multiply the first number (a=1) by 9. The resulting sequence will be [9,6,3]. This is an AP with a difference d=−3.

在第四个测试用例中,您可以选择m=9,并将第一个数字(a=1)乘以9。结果序列将为[9,6,3]。这是一个不同于d的AP=−3.

In the fifth test case, it is impossible to make an AP.

在第五个测试用例中,不可能生成AP。

CodeForces 文章被收录于专栏

https://codeforces.ml/

全部评论

相关推荐

1 收藏 评论
分享
牛客网
牛客企业服务