欢迎光临散文网 会员登陆 & 注册

CF 1857A - Array Coloring

2023-08-11 09:17 作者:您是打尖儿还是住店呢  | 我要投稿

You are given an array consisting of n integers. Your task is to determine whether it is possible to color all its elements in two colors in such a way that the sums of the elements of both colors have the same parity and each color has at least one element colored.

For example, if the array is [1,2,4,3,2,3,5,4], we can color it as follows: [1,2,4,3,2,3,5,4], where the sum of the blue elements is 6 and the sum of the red elements is 18.

Input

The first line contains an integer t (1≤t≤1000) — the number of test cases.

Each test case begins with a line containing an integer n (2≤n≤50) — the length of the array a.

The next line contains n integers a1,a2,…,an (1≤ai≤50) — the elements of the array a.


Output

For each test case, output "YES" (without quotes) if it is possible to color the array in two colors in such a way that the sums of the elements of both colors have the same parity and each color has at least one element colored, and "NO" otherwise.


You can output "Yes" and "No" in any case (for example, the strings "yES", "yes", and "Yes" will be recognized as correct answers).

---------------------------------------------------------

给定一个由 n 个整数组成的数组。 您的任务是确定是否可以将其所有元素着色为两种颜色,使得两种颜色的元素之和具有相同的奇偶性,并且每种颜色至少有一个元素着色。

例如,如果数组是[1,2,4,3,2,3,5,4],我们可以将其着色如下:[1,2,4,3,2,3,5,4], 其中蓝色元素的总和为 6,红色元素的总和为 18。

输入

第一行包含一个整数 t (1≤t≤1000) — 测试用例的数量。

每个测试用例都以包含整数 n (2≤n≤50) 的行开始 — 数组 a 的长度。

下一行包含 n 个整数 a1,a2,…,an (1≤ai≤50) — 数组 a 的元素。


输出

对于每个测试用例,如果可以用两种颜色对数组进行着色,使得两种颜色的元素之和具有相同的奇偶性,并且每种颜色至少有一个元素着色,则输出“YES”(不带引号) ,否则为“否”。


您可以在任何情况下输出“Yes”和“No”(例如,字符串“yES”、“yes”和“Yes”将被识别为正确答案)。

---------------------------------

题意转换,只要和是偶数,那么就可以组成,反之不可以;

下面是代码:


CF 1857A - Array Coloring的评论 (共 条)

分享到微博请遵守国家法律