CodeForces - 1622A Construct a Rectangle水题
Posted 海岛Blog
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CodeForces - 1622A Construct a Rectangle水题相关的知识,希望对你有一定的参考价值。
A. Construct a Rectangle
time limit per test2 seconds
memory limit per test256 megabytes
There are three sticks with integer lengths l1,l2 and l3.
You are asked to break exactly one of them into two pieces in such a way that:
both pieces have positive (strictly greater than 0) 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 t (1≤t≤104) — the number of testcases.
The only line of each testcase contains three integers l1,l2,l3 (1≤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
4
6 1 5
2 5 2
2 4 2
5 5 4
output
YES
NO
YES
YES
Note
In the first testcase, the first stick can be broken into parts of length 1 and 5. We can construct a rectangle with opposite sides of length 1 and 5.
In the second testcase, breaking the stick of length 2 can only result in sticks of lengths 1,1,2,5, which can’t be made into a rectangle. Breaking the stick of length 5 can produce results 2,3 or 1,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 2 and 2. The resulting rectangle has opposite sides 2 and 2 (which is a square).
In the fourth testcase, the third stick can be broken into parts of length 2 and 2. The resulting rectangle has opposite sides 2 and 5.
问题链接:CodeForces - 1622A Construct a Rectangle
问题简述:(略)
问题分析:(略)
AC的C语言程序如下:
/* CodeForces - 1622A Construct a Rectangle */
#include <stdio.h>
#define N 3
int l[N];
int main()
int t;
scanf("%d", &t);
while (t--)
for (int i = 0; i < N; i++)
scanf("%d", &l[i]);
int ans = 0;
if (l[0] == l[1] + l[2] || l[1] == l[0] + l[2] || l[2] == l[0] + l[1] ||
(l[0] == l[1] && l[2] % 2 == 0) ||
(l[0] == l[2] && l[1] % 2 == 0) ||
(l[1] == l[2] && l[0] % 2 == 0))
ans = 1;
printf(ans ? "YES\\n" : "NO\\n");
return 0;
以上是关于CodeForces - 1622A Construct a Rectangle水题的主要内容,如果未能解决你的问题,请参考以下文章
Scipy:如何将 Bounds 与 trust-constr 一起使用?
flake8 和 Pydantic 约束类型的语法错误:constr(regex=)
scipy.optimize.minimize(method='trust-constr') 不会在 xtol 条件下终止
ConfigurationManager.AppSettings["conStr"]是啥意思?要详细解释~~O(∩_∩)O~
SQLSTATE[HY000]: 一般错误: 1005 Can't create table `school`.`posts` (errno: 150 "Foreign key constr