每日一题 第九十四期 Codeforces Round 903 (Div. 3)

B. Three Threadlets

time limit per test: 2 seconds

memory limit per test: 256 megabytes

input: standard input

output: standard output
Once upon a time, bartender Decim found three threadlets and a pair of scissors.

In one operation, Decim chooses any threadlet and cuts it into two threadlets, whose lengths are positive integers and their sum is equal to the length of the threadlet being cut.

For example, he can cut a threadlet of length 5 5 5 into threadlets of lengths 2 2 2 and 3 3 3, but he cannot cut it into threadlets of lengths 2.5 2.5 2.5 and 2.5 2.5 2.5, or lengths 0 0 0 and 5 5 5, or lengths 3 3 3 and 4 4 4.

Decim can perform at most three operations. He is allowed to cut the threadlets obtained from previous cuts. Will he be able to make all the threadlets of equal length?

Input

The first line contains an integer t t t ( 1 ≤ t ≤ 1 0 4 1 \le t \le 10^4 1t104) — the number of test cases. Then follows the description of each test case.

In a single line of each test case, there are three integers a a a, b b b, c c c ( 1 ≤ a , b , c ≤ 1 0 9 1 \le a, b, c \le 10^9 1a,b,c109) — the lengths of the threadlets.

Output

For each test case, output “YES” if it is possible to make all the threadlets of equal length by performing at most three operations, otherwise output “NO”.

You can output “YES” and “NO” in any case (for example, the strings “yEs”, “yes”, “Yes”, and “YES” will be recognized as a positive answer).

Example
inputCopy
15
1 3 2
5 5 5
6 36 12
7 8 7
6 3 3
4 4 12
12 6 8
1000000000 1000000000 1000000000
3 7 1
9 9 1
9 3 6
2 8 2
5 3 10
8 4 8
2 8 4
outputCopy
YES
YES
NO
NO
YES
YES
NO
YES
NO
NO
YES
YES
NO
YES
NO

AC代码:

#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int>PII;
const int N=3e5+10;
const int MOD=9901;
const int INF=0X3F3F3F3F;
const int dx[]={-1,1,0,0,-1,-1,+1,+1};
const int dy[]={0,0,-1,1,-1,+1,-1,+1};
const int M = 1e6 + 10;
 
int t;
ll a, b, c;
int main()
{
	cin >> t;
	while(t --){
		cin >> a >> b >> c;
		ll mins = min({a, b , c});
		ll maxs = max({a, b , c});
		ll mid = a + b + c - mins - maxs;
		int gcds = gcd(a, gcd(b, c));
		if(mins / gcds + mid / gcds + maxs / gcds - 3 <= 3) puts("YES");
		else puts("NO");
	}
	return 0;
}
  • 23
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值