QOJ.ac

QOJ

Time Limit: 2.0 s Memory Limit: 1024 MB Total points: 100 Hackable ✓

#16272. 整数组

Statistics

给你一个由 $n$ 个正整数组成的数组 $a$,下标从 $1$ 到 $n$。如果对于该数组中的任意两个(不一定不同)数 $x$ 和 $y$,满足 $x \ge y$ 时,数 $\lfloor \frac{x}{y} \rfloor$($x$ 除以 $y$ 向下取整)也在该数组中,则称该数组是完整的(integral)。

保证 $a$ 中的所有数均不超过 $c$。你的任务是判断该数组是否是完整的。

输入格式

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

每个测试用例的第一行包含两个整数 $n$ 和 $c$ ($1 \le n \le 10^6$,$1 \le c \le 10^7$) —— 数组 $a$ 的大小和数组中元素的最大限制。

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

设 $N$ 为所有测试用例中 $n$ 的总和,$C$ 为所有测试用例中 $c$ 的总和。保证 $N \le 10^6$ 且 $C \le 10^7$。

输出格式

对于每个测试用例,如果数组是完整的,输出 Yes,否则输出 No

样例

输入样例 1

3
3 5
1 2 5
4 10
1 3 3 7
1 2
2

输出样例 1

Yes
No
No

说明

在第一个测试用例中,很容易看出该数组是完整的:

  • $\lfloor \frac{1}{1} \rfloor = 1$,$a_1 = 1$,该数在数组中
  • $\lfloor \frac{2}{2} \rfloor = 1$
  • $\lfloor \frac{5}{5} \rfloor = 1$
  • $\lfloor \frac{2}{1} \rfloor = 2$,$a_2 = 2$,该数在数组中
  • $\lfloor \frac{5}{1} \rfloor = 5$,$a_3 = 5$,该数在数组中
  • $\lfloor \frac{5}{2} \rfloor = 2$,$a_2 = 2$,该数在数组中

因此,条件满足,数组是完整的。

在第二个测试用例中,只需看到 $\lfloor \frac{7}{3} \rfloor = \lfloor 2\frac{1}{3} \rfloor = 2$,而该数不在 $a$ 中,所以它不是完整的。

在第三个测试用例中,$\lfloor \frac{2}{2} \rfloor = 1$,但数组中只有 $2$,所以它不是完整的。

子任务

本题的测试点分为 7 个组。对于每个组,只有当你的程序通过该组中的所有测试以及所有依赖组中的测试时,才能获得该组的分数。

组别 分数 附加限制 $N$ 附加限制 $C$ 依赖组别 备注
0 0 - - - 样例测试
1 13 $N \le 100$ - 0
2 17 $N \le 100\,000$ $C \le 10\,000$ 0
3 15 $N \le 1000$ - 0, 1
4 27 $N \le 100\,000$ - 0 - 3
5 28 - - 0 - 4

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

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.