QOJ.ac

QOJ

Limite de temps : 3.0 s Limite de mémoire : 512 MB Points totaux : 100 Hackable ✓

#8144. 游戏

Statistiques

很久以前,有两位圣人,名叫圣爱丽丝(St. Alice)和圣鲍勃(St. Bob)。 由于当圣人实在太无聊了,他们决定玩一个游戏。这个游戏与整除性有关。 现有两个整数集合,分别称为 $A$ 和 $B$。另有两个整数 $\alpha, \beta$。初始时,$\alpha = \beta = 1$。 随后,他们轮流进行操作。首先由爱丽丝进行第一回合,接着是鲍勃,然后是爱丽丝,鲍勃,爱丽丝,以此类推。 在爱丽丝的回合,她必须从 $A$ 中选择一个数 $x$,并将 $\alpha$ 更新为 $\alpha \times x$。 在鲍勃的回合,他必须从 $B$ 中选择一个数 $x$,并将 $\beta$ 更新为 $\beta \times x$。 如果在某个时刻 $\alpha \mid \beta$(即存在整数 $k$ 使得 $k \times \alpha = \beta$),则鲍勃获胜。爱丽丝无法获胜,她只想让游戏永远进行下去。 两位圣人都很聪明,因此双方都会采取最优策略(以获胜或不输)。 经过一些实验,爱丽丝发现游戏太简单了,所以她想删除 $A$ 的一个子集,同时保持她处于不败之地。如果删除某个子集后,爱丽丝的不败地位不受影响,则称该子集为合法的。 圣人们长生不老,他们一直在玩这个游戏。爱丽丝请求你计算 $A$ 中合法子集的数量,你能做到吗?

输入格式

第一行包含两个整数 $|A|, |B|$ ($1 \le |A|, |B| \le 500$),分别表示集合 $A$ 和 $B$ 的元素个数。 第二行包含 $|A|$ 个整数 $a_i$ ($2 \le a_i \le 500, a_i < a_{i+1}$),表示集合 $A$ 的元素。 第三行包含 $|B|$ 个整数 $b_i$ ($2 \le b_i \le 500, b_i < b_{i+1}$),表示集合 $B$ 的元素。

输出格式

输出一个整数,表示 $A$ 中合法子集的数量,对 $10^9 + 7$ 取模。 即使爱丽丝什么都不删,鲍勃也可能获胜,这意味着圣人们在戏弄你,但无论如何请输出 0。

样例

样例输入 1

2 3
2 6
6 7 8

样例输出 1

2

样例输入 2

6 13
6 7 12 18 21 29
8 11 12 13 15 16 20 21 23 24 27 28 30

样例输出 2

56

说明

在第一个样例中,$\{2\}$ 和 $\emptyset$ 是仅有的两个合法子集。

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.