#P7224. Counting Subsets with Product Greater Than m
Counting Subsets with Product Greater Than m
Counting Subsets with Product Greater Than m
You are given n integers \(a_1, a_2, \dots, a_n\) forming a multiset. A subset is defined by the indices of the elements you choose; two subsets are considered different if and only if the sets of indices they contain are different. The product of the elements in a subset is defined in the natural way, and by convention the product of the empty set is \(1\).
Your task is to count how many subsets have a product strictly greater than \(m\). Since the answer may be very large, output your answer modulo \(998244353\).
Mathematical Definition:
Find the number of subsets \(S\) such that \[ \prod_{i \in S} a_i > m, \quad \text{with } \prod_{i \in \emptyset} a_i = 1. \]
inputFormat
The first line contains two integers n and m — the number of elements and the threshold, respectively.
The second line contains n integers \(a_1, a_2, \dots, a_n\), which represent the elements of the multiset.
Constraints: It is guaranteed that n is small enough to allow iterating over all \(2^n\) subsets. All \(a_i\) and \(m\) are positive integers.
outputFormat
Output a single integer: the number of subsets whose product is greater than \(m\), taken modulo \(998244353\).
sample
3 2
1 2 3
4
</p>