PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000332. Đếm dãy con có bội chung nhỏ nhất bằng M (Subsequence LCM)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Đếm dãy con có bội chung nhỏ nhất bằng M (Subsequence LCM)

Subsequence LCM

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

You are given NN positive integers A1,…,ANA_1,\dots,A_N and a positive integer MM. Count the ways to select at least one position such that the least common multiple (LCM) of all selected elements is exactly MM.

The selected positions need not be contiguous; their original order is preserved. Different sets of positions are counted separately, even when their selected values are identical. The LCM of a one-element sequence is that element.

Print the count modulo 998244353998244353.

Input

The first line contains N,MN,M; the second contains A1,A2,…,ANA_1,A_2,\dots,A_N.

Output

Print the number of valid subsequences modulo 998244353998244353.

Subtasks

  • Subtask 1 (20 points): 1≤N≤161\le N\le 16, 1≤M,Ai≤1051\le M,A_i\le 10^5.
  • Subtask 2 (30 points): 1≤N≤20001\le N\le 2000, 1≤M,Ai≤10101\le M,A_i\le 10^{10}.
  • Subtask 3 (50 points): 1≤N≤2⋅1051\le N\le 2\cdot10^5, 1≤M,Ai≤10161\le M,A_i\le 10^{16}.

Examples

Example 1

Input

4 6
2 3 4 6

Output

5

Explanation

The value 44 cannot appear since it does not divide 66. The valid selections are (2,3)(2,3), (2,3,6)(2,3,6), (2,6)(2,6), (3,6)(3,6) and (6)(6): five ways.

Example 2

Input

5 349
1 1 1 1 349

Output

16

Explanation

The element 349349 must be selected, while each of the four ones may independently be included or excluded: 24=162^4=16.

Example 3

Input

16 720720
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

Output

2688

Explanation

Since 720720=24⋅32⋅5⋅7⋅11⋅13720720=2^4\cdot3^2\cdot5\cdot7\cdot11\cdot13, the values 16,9,11,1316,9,11,13 are mandatory. Choose a nonempty subset of {7,14}\{7,14\} and a nonempty subset of {5,10,15}\{5,10,15\} to supply 77 and 55. Each of the remaining seven positions may be included or skipped. The count is 3⋅7⋅27=26883\cdot7\cdot2^7=2688.

Note: Each input file contains one case using the specified format.