QOJ.ac

QOJ

Time Limit: 3.5 s Memory Limit: 64 MB Total points: 100

#13301. 优惠券

Statistics

Byteasar 拥有的糖果店出售美味的焦糖糖果。对于每一个正整数 $c$,都有且仅有一个包装内含 $c$ 颗糖果;目前预计不会有新的补货。为了鼓励顾客购买糖果,Byteasar 在一些包装中放入了 $m$ 张年度巧克力供应券,并确保每个包装中最多只有一张券。

Byteburg 的嘉年华将于下周开始,持续 $n$ 天;在嘉年华的第 $k$ 天,将举办一场有 $a_k$ 位客人的派对。Byteasar 确信,在第 $k$ 天的早上,每一位客人都会在他的店里购买能被派对客人人数整除的最小包装的糖果。例如,如果 $n=2, a_1=4, a_2=2$,那么在嘉年华的第一天,他预计会卖出包含 4, 8, 12, 16 颗糖果的包装,而在第二天会卖出包含 2, 6 颗糖果的包装。

现在他想知道哪些顾客会买到带有奖券的包装。他请求你编写一个程序来帮他确定这一点。

输入格式

标准输入的第一行包含一个整数 $m$ ($1 \le m \le 1,000,000$),表示奖券的数量。接下来的 $m$ 行,第 $k$ 行包含一个整数 $b_k$ ($1 \le b_k \le 1,000,000$),表示 Byteasar 在第 $k$ 张奖券所在的包装中放入的糖果数量。这些数字按升序给出。

接下来的一行包含一个整数 $n$ ($1 \le n \le 1,000,000$),表示嘉年华的天数。接下来的 $n$ 行,第 $k$ 行包含一个整数 $a_k$ ($1 \le a_k \le 1,000,000$),表示参加第 $k$ 天派对的客人人数。

输出格式

在标准输出的第一行,你的程序应打印一个整数 $z$,表示售出的带有奖券的包装数量。接下来的 $z$ 行应按升序输出买到带有奖券包装的顾客编号。顾客按购买顺序从 1 开始编号。

样例

输入 1

4
1
6
8
16
3
4
2
4

输出 1

3
2
4
6

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.