Make AP CodeForces - 1624B

Polycarp has 333 positive integers aaa, bbb and ccc. He can perform the following operation exactly once.

  • Choose a positive integer mmm and multiply exactly one of the integers aaa, bbb or ccc by mmm.

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

Formally, a sequence x1,x2,…,xnx_1, x_2, \dots, x_nx1​,x2​,…,xn​ is called an arithmetic progression (AP) if there exists a number ddd (called "common difference") such that xi+1=xi+dx_{i+1}=x_i+dxi+1​=xi​+d for all iii from 111 to n−1n-1n−1. In this problem, n=3n=3n=3.

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

You need to answer ttt independent test cases.

Input

The first line contains the number ttt (1≤t≤1041 \le t \le 10^41≤t≤104) — the number of test cases.

Each of the following ttt lines contains 333 integers aaa, bbb, ccc (1≤a,b,c≤1081 \le a, b, c \le 10^81≤a,b,c≤108).

Output

For each test case print "YES" (without quotes) if Polycarp can choose a positive integer mmm and multiply exactly one of the integers aaa, bbb or ccc by mmm to make [a,b,c][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).

Sample 1

InputcopyOutputcopy
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
YES
YES
YES
YES
NO
YES
NO
YES
YES
NO
YES

 这个题要我们将输入的三个数中其中一个数乘K,之后使这三个数成为一个等差数列。

等差数列的性质:a+c=2b。

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main()
{
	int t;cin>>t;
	while(t--)
	{
		int a,b,c;
		cin>>a>>b>>c;
		if(a+c==2*b)
			cout<<"YES"<<endl;
		else 
		{
			if(2*b<a+c)
			{
				if((a+c)%(2*b)==0) 	cout<<"YES"<<endl;
				else 	cout<<"NO"<<endl;
			}
			else 
			{
				if((2*b-c)%a==0||(2*b-a)%c==0)
					cout<<"YES"<<endl;
				else 
					cout<<"NO"<<endl;
			}
			
		}
			
	}
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值