QOJ.ac

QOJ

Límite de tiempo: 1.0 s Límite de memoria: 256 MB Puntuación total: 100 Hackeable ✓

#7932. AND-OR 闭包

Estadísticas

给定一个包含 $n$ 个非负整数的集合 $A$,我们定义其 AND-OR 闭包为满足以下条件的最小集合 $B$:

  • $A \subseteq B$
  • 若 $x, y \in B$,则 $(x \text{ AND } y) \in B$
  • 若 $x, y \in B$,则 $(x \text{ OR } y) \in B$

求 $A$ 的 AND-OR 闭包的大小。

其中 AND 表示按位与运算,OR 表示按位或运算。

输入格式

第一行包含一个整数 $n$ ($1 \le n \le 2 \cdot 10^5$),表示集合 $A$ 的大小。

第二行包含 $n$ 个不同的整数 $a_1, a_2, \dots, a_n$ ($0 \le a_i < 2^{40}$),表示集合 $A$ 中的元素。

输出格式

输出 $A$ 的 AND-OR 闭包的大小。

样例

输入格式 1

4
0 1 3 5

输出格式 1

5

说明

在第一个样例中,$A$ 的 AND-OR 闭包为 $\{0, 1, 3, 5, 7\}$。

输入格式 2

5
0 1 2 3 4

输出格式 2

8

说明

在第二个样例中,$A$ 的 AND-OR 闭包为 $\{0, 1, 2, 3, 4, 5, 6, 7\}$。

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.