#P5887. Ringed Genesis
Ringed Genesis
Description
There is a long ring made by connecting cells end to end, numbered from to in order.
There is also an animal called a rabbit. The rabbit’s step length is . If the rabbit is currently on the -th cell, then in the next second it will jump to the -th cell.
Now there are rabbits. The initial cell of the -th rabbit is the -th cell. As time goes by, some cells are visited by rabbits, while some cells are never visited.
You need to find how many cells can never be visited by any rabbit.
Input Format
Read input from standard input.
The first line contains three positive integers , representing the ring length, the number of rabbits, and the step length.
The second line contains non-negative integers , representing the initial cells of the rabbits.
Output Format
Write output to standard output.
Output one line with one integer, which is the answer.
4 2 2
0 1
0
4 2 2
0 2
2
Hint
Subtask 1 (): .
Subtask 2 (): , i.e. .
Subtask 3 (): , .
Subtask 4 (): no special constraints.
For all testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号