Interval-Free Permutations
- 시간 제한
- 2s
- 메모리 제한
- 512MB
- 제출
- 1
- 정답
- 1
- 맞힌 사람
- 1
- 정답 비율
- 100.0%
문제
Consider a permutation of integers from 1 to . We call a sub-segment of the permutation an interval if it is a reordering of some set of consecutive integers. For example, the permutation has the intervals , , , and others.
Each permutation has some trivial intervals — the full permutation itself and every single element. We call a permutation interval-free if it does not have non-trivial intervals. In other words, interval-free permutation does not have intervals of length between 2 and inclusive.
Your task is to count the number of interval-free permutations of length modulo prime number .
입력
In the first line of the input there are two integers () and () — the number of test cases to solve and the prime modulo. In each of the next lines there is one integer () — the length of the permutation.
출력
For each of test cases print a single integer — the number of interval-free permutations modulo .
예제 입력 1
4 998244353
1
4
5
9
예제 출력 1
1
2
6
28146
예제 입력 2
1 437122297
20
예제 출력 2
67777575
노트
For the only permutation is interval-free. For two interval-free permutations are and . For — , , , , , and . We will not list all 28146 for , but for example , , , and are interval-free.
The exact value for is 264111424634864638.
코드를 제출하려면 로그인이 필요합니다.
로그인제출 내역이 없습니다.
| # | 순위 | 사용자 | 언어 | 시간 | 메모리 | 코드 길이 | |
|---|---|---|---|---|---|---|---|
| 9890 | 🥇 | 옥찬호 | Rust | 55ms | 3180KB | 2338B |
| # | 사용자 | 문제 | 결과 | 언어 | 시간 | 메모리 | 코드 길이 | 제출 시간 | |
|---|---|---|---|---|---|---|---|---|---|
| 9890 | 맞았습니다 | Rust | 55ms | 3180KB | 2338B | 2026. 09. 22. 14:40 |