CF1624B.Make AP

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Polycarp has 33 positive integers aa , bb and cc . He can perform the following operation exactly once.

  • Choose a positive integer mm and multiply exactly one of the integers aa , bb or cc by mm .

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

Formally, a sequence x1,x2,,xnx_1, x_2, \dots, x_n is called an arithmetic progression (AP) if there exists a number dd (called "common difference") such that xi+1=xi+dx_{i+1}=x_i+d for all ii from 11 to n1n-1 . In this problem, n=3n=3 .

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

You need to answer tt independent test cases.

输入格式

The first line contains the number tt ( 1t1041 \le t \le 10^4 ) — the number of test cases.

Each of the following tt lines contains 33 integers aa , bb , cc ( 1a,b,c1081 \le a, b, c \le 10^8 ).

输出格式

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

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).

输入输出样例

  • 输入#1

    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

    输出#1

    YES
    YES
    YES
    YES
    NO
    YES
    NO
    YES
    YES
    NO
    YES

说明/提示

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

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

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

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

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

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

首页