luogu#P5216. DLS 采花
DLS 采花
Background
A very easy check-in problem.
Problem Description
DLS has flower fields, and the -th field has flowers.
DLS likes strange and unusual flower fields. He wants to rearrange the fields and then pick flowers.
However, DLS has another habit when picking flowers: he picks from left to right.
When he reaches the -th field, if among the fields before it there is a field whose number of flowers is a divisor of the number of flowers in the -th field, then DLS will not pick any flowers from this field.
Now, DLS wants to know, over all permutations of the fields, what the total sum of the number of flowers he can pick is.
Since the answer can be large, output it modulo .
Input Format
The first line contains a positive integer .
The second line contains a sequence of length .
Output Format
Output one line: the sum of the number of flowers picked over all permutations, modulo .
4
2 3 6 3
156
Hint
| Data Percentage | Constraints |
|---|---|
Translated by ChatGPT 5