#abc349f. F - Subsequence LCM
F - Subsequence LCM
Score: points
问题陈述
给定一个正整数序列 ,长度为 ,以及一个正整数 。找出非空且不一定要连续的 的子序列的数量,模 ,使得子序列中元素的最小公倍数(LCM)为 。如果它们在序列中的位置不同,即使作为序列它们相同,也认为两个子序列是不同的。此外,单个元素序列的 LCM 就是该元素本身。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
You are given a sequence of positive integers of length and a positive integer . Find the number, modulo , of non-empty and not necessarily contiguous subsequences of such that the least common multiple (LCM) of the elements in the subsequence is . Two subsequences are distinguished if they are taken from different positions in the sequence, even if they coincide as sequences. Also, the LCM of a sequence with a single element is that element itself.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
4 6
2 3 4 6
Sample Output 1
5
The subsequences of whose elements have an LCM of are ; there are five of them.
Sample Input 2
5 349
1 1 1 1 349
Sample Output 2
16
Note that even if some subsequences coincide as sequences, they are distinguished if they are taken from different positions.
Sample Input 3
16 720720
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Sample Output 3
2688