#P10099. [ROIR 2023] 美丽序列 (Day 2)
[ROIR 2023] 美丽序列 (Day 2)
Background
Translated from ROIR 2023 D2T2。
You are given an integer set , where all elements are between and .
A sequence of length consisting of integers from set is called beautiful if, for any number , the distance between any two elements equal to in the sequence is at least . In other words, for any number and any , if , then the inequality must hold. Such a sequence is called a beautiful sequence.
For example, when , the sequence is beautiful, while is not beautiful, because the distance between the two 's in this sequence is .
Problem Description
Given the number and the set , find the number of beautiful sequences of length that satisfy the requirement, modulo .
Input Format
The first line contains two integers and , representing the length of the sequence and the number of elements in set .
The second line gives distinct positive integers in ascending order, each not exceeding , representing the elements of set .
Output Format
Output one integer, the remainder of the number of beautiful sequences modulo .
3 2
1 2
5
Hint
In the sample, the beautiful sequences are . The sequences are not beautiful, because in each of these three sequences there are two elements with value whose distance is .
This problem uses bundled testdata.
| Subtask ID | Score | Special Properties |
|---|---|---|
| () | ||
| No element in is greater than | ||
| No special properties |
Constraints: for of the testdata, 。
Translated by ChatGPT 5