PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000239. Đếm tập ổn định khi đổi thứ tự phép chia dư (Modular Stability)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đếm tập ổn định khi đổi thứ tự phép chia dư (Modular Stability)
Đếm tập ổn định khi đổi thứ tự phép chia dư (Modular Stability)
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Count strictly increasing arrays of length with elements from such that, for any nonnegative integer , applying successive modulo operations with the array elements gives the same result in every order. Print the count modulo .
Input
One line with .
Output
Print the number of stable arrays modulo .
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Example 1
Input
7 3
Output
16
Explanation
There are valid arrays starting with 1 and one further array .
Example 2
Input
3 7
Output
0
Explanation
It is impossible to select seven distinct values between 1 and 3.