#P9391. 红草莓

红草莓

Problem Description

There is a necklace made of nn pearls. The necklace is a ring, with the head and tail connected. One pearl has a special mark, and we call it the starting pearl.

An alien is very good at shooting cosmic rays. It shoots cosmic rays for mm rounds in order. In round ii, there is a parameter aia_i, which means:

  • The alien starts counting from the starting pearl. The starting pearl is numbered 00, the next pearl is numbered 11, and so on. After finishing one full circle, it continues counting (for example, pearl nn is still the starting pearl, and pearl n+1n+1 is the next pearl after the starting pearl). The alien will shoot one cosmic ray at every pearl whose number is a multiple of aia_i, i.e., pearls numbered 0,ai,2ai,0, a_i, 2a_i, \dots.

At the beginning, all pearls are red. Once a pearl is hit by a cosmic ray, it will be dyed from red to blue.

You need to output: for each round of operation, how many pearls that were red before this round are turned blue by this round.

Input Format

The first line: two integers n,mn, m.

The second line: mm integers a1,,ama_1, \dots, a_m.

Output Format

The first line: mm integers, where the ii-th integer denotes how many pearls that were red before round ii are turned blue in that round.

6 6
6 3 4 2 5 1

1 1 2 0 2 0

Hint

Sample Explanation

The figure shows the colors of the pearls initially and after each operation. The starting pearl is numbered 00. You can see that the numbers of newly dyed blue pearls in each operation are 1,1,2,0,2,01, 1, 2, 0, 2, 0 respectively:


Constraints

For all testdata: 1n,m5×1051 \leq n, m \leq 5 \times 10^5, 1ain1 \leq a_i \leq n.

Subtask ID nn \leq mm \leq Special Restriction Score
Subtask 1\text{Subtask 1} 100100 None 1515
Subtask 2\text{Subtask 2} 10001000
Subtask 3\text{Subtask 3} 10510^5 10510^5 aina_i \mid n 2020
Subtask 4\text{Subtask 4} 1010 None
Subtask 5\text{Subtask 5} 5×1055 \times 10^5 3030

Translated by ChatGPT 5