ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

A. Construct a Rectangle

2022-01-16 21:02:58  阅读:396  来源: 互联网

标签:22 into Construct length Rectangle YES rectangle stick


time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

There are three sticks with integer lengths l1,l2l1,l2 and l3l3.

You are asked to break exactly one of them into two pieces in such a way that:

  • both pieces have positive (strictly greater than 00) integer length;
  • the total length of the pieces is equal to the original length of the stick;
  • it's possible to construct a rectangle from the resulting four sticks such that each stick is used as exactly one of its sides.

A square is also considered a rectangle.

Determine if it's possible to do that.

Input

The first line contains a single integer tt (1≤t≤1041≤t≤104) — the number of testcases.

The only line of each testcase contains three integers l1,l2,l3l1,l2,l3 (1≤li≤1081≤li≤108) — the lengths of the sticks.

Output

For each testcase, print "YES" if it's possible to break one of the sticks into two pieces with positive integer length in such a way that it's possible to construct a rectangle from the resulting four sticks. Otherwise, print "NO".

You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES are all recognized as a positive answer).

Example

input

Copy

4
6 1 5
2 5 2
2 4 2
5 5 4

output

Copy

YES
NO
YES
YES

Note

In the first testcase, the first stick can be broken into parts of length 11 and 55. We can construct a rectangle with opposite sides of length 11 and 55.

In the second testcase, breaking the stick of length 22 can only result in sticks of lengths 1,1,2,51,1,2,5, which can't be made into a rectangle. Breaking the stick of length 55 can produce results 2,32,3 or 1,41,4 but neither of them can't be put into a rectangle.

In the third testcase, the second stick can be broken into parts of length 22 and 22. The resulting rectangle has opposite sides 22 and 22 (which is a square).

In the fourth testcase, the third stick can be broken into parts of length 22 and 22. The resulting rectangle has opposite sides 22 and 55.

解题说明:此题是一道几何题,简单分析就知道如果要构成矩形,一种情况是两个数之和等于第三个数,这样把第三个数拆分即可。另一种情况是其中两个数相等,第三个数能被2整除,这样只需要把第三个数对半拆即可。

#include<stdio.h>
int main()
{
	int t;
	scanf("%d", &t);
	while (t--) 
	{
		int l, m, n;
		scanf("%d %d %d", &l, &m, &n);
		if (l == m + n || m == l + n || n == l + m || (l == m && n % 2 == 0) || (l == n && m % 2 == 0) || (m == n && l % 2 == 0)) 
		{
			printf("YES\n");
		}
		else 
		{
			printf("NO\n");
		}

	}
	return 0;
}

标签:22,into,Construct,length,Rectangle,YES,rectangle,stick
来源: https://blog.csdn.net/jj12345jj198999/article/details/122528616

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有