PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000115. Đếm dãy có BCNN kề nhau bằng k (Counting LCM Arrays)
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 dãy có BCNN kề nhau bằng k (Counting LCM Arrays)
Counting LCM Arrays
Source: CSES
Version: Phuoc Hung OJ Extended
Problem Statement
Given positive integers , count arrays of positive integers such that for all . Print the count modulo . Arrays differing at any position are distinct.
Input
One line containing .
Output
Print the number of valid arrays modulo .
Subtasks
- Subtask 1 (20 points): , .
- Subtask 2 (30 points): , .
- Subtask 3 (50 points): , .
Examples
Input
3 4
Output
11
Explanation
Since , each entry belongs to . Exactly arrays of length have every adjacent LCM equal to .