QOJ.ac

QOJ

时间限制: 1.0 s 内存限制: 256 MB 总分: 100 可 Hack ✓

#17289. Doremy's Paint 3

统计

一个由正整数组成的数组 $b_1, b_2, \dots, b_n$ 被称为好的,当且仅当所有相邻两个元素的和都相等。更正式地,如果存在一个常数 $k$,使得 $b_1 + b_2 = b_2 + b_3 = \dots = b_{n-1} + b_n = k$,则该数组是好的。

Doremy 有一个长度为 $n$ 的数组 $a$。现在 Doremy 可以任意重新排列它的元素(改变它们的顺序)。请判断她是否能使该数组变成好的。

输入格式

输入包含多个测试用例。第一行包含一个整数 $t$ ($1 \le t \le 100$) — 测试用例的数量。接下来是每个测试用例的描述。

每个测试用例的第一行包含一个整数 $n$ ($2 \le n \le 100$) — 数组 $a$ 的长度。

每个测试用例的第二行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^5$)。

所有测试用例中 $n$ 的总和没有额外限制。

输出格式

对于每个测试用例,如果可以使数组变好,则输出 "Yes"(不带双引号),否则输出 "No"(不带双引号)。

你可以输出任意大小写的答案。例如,字符串 "yEs"、"yes"、"Yes" 和 "YES" 都会被识别为肯定的回答。

样例

输入样例 1

5
2
8 9
3
1 1 2
4
1 1 4 5
5
2 3 3 3 3
4
100000 100000 100000 100000

输出样例 1

Yes
Yes
No
No
Yes

说明

在第一个测试用例中,$[8, 9]$ 和 $[9, 8]$ 都是好的。

在第二个测试用例中,$[1, 2, 1]$ 是好的,因为 $a_1 + a_2 = a_2 + a_3 = 3$。

在第三个测试用例中,可以证明没有任何排列是好的。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.