#P15789. [JAG 2025 Summer Camp #3] Broken Scale

[JAG 2025 Summer Camp #3] Broken Scale

题目描述

You are an airport receptionist at Jag Airlines Group. There are NN passengers, and you have received one piece of baggage from each of them. From the check-in records, you know that the weight of passenger ii's baggage is AiA_i kilograms.

However, you forgot to attach labels to the bags.

If you assign random labels to the bags, the probability of attaching the correct label to all baggage is 1N!\frac{1}{N!}, which is far too low. While thinking of ways to increase this probability, you find a slightly broken electronic scale in the warehouse.

After some investigation, you find that when items are placed on this scale, it displays the largest value among B0,B1,B2,B^0, B^1, B^2, \ldots (in kilograms) that does not exceed the actual total weight. Here, BB is a given integer with B2B \geq 2.

You may place any non-empty subset of the bags on the scale, and you may repeat this as many times as you like. Find the maximum probability of attaching the correct label to all baggage if you act optimally, and output it modulo 998244353=119×223+1998244353 = 119 \times 2^{23} + 1.

What is probability modulo 998244353998244353?

It can be proved that the sought probabilities will always be rational numbers. Under the constraints of this problem, it can also be proved that when expressing the value as PQ\frac{P}{Q} using two coprime integers PP and QQ, there is exactly one integer RR satisfying R×QP(mod998244353)R \times Q \equiv P \pmod{998244353} and 0R<9982443530 \leq R < 998244353. Find this RR.

输入格式

The input consists of multiple test cases.

The first line contains an integer TT (1T101 \leq T \leq 10), representing the number of test cases.

TT test cases follow. Each test case is given in the following format.

$$\begin{aligned} & N \ B \\ & A_1 \ A_2 \ \ldots \ A_N \end{aligned}$$

For each test case, the first line contains integers NN (1N3001 \leq N \leq 300) and BB (2B15002 \leq B \leq 1500), representing the number of pieces of baggage and the parameter of the electronic scale, respectively.

The next line contains NN integers AiA_i (1A1A2AN15001 \leq A_1 \leq A_2 \leq \cdots \leq A_N \leq 1500), representing the weight of passenger ii's baggage.

Additionally, the sum of NN over all test cases does not exceed 300300.

输出格式

For the TT test cases, output the answers separated by newlines. For each test case, output the maximum probability of attaching the correct label to all baggage if you act optimally.

3
3 3
9 15 17
5 23
41 41 41 41 41
14 10
101 102 103 104 105 106 107 108 109 110 111 112 113 114
499122177
856826403
314148269

提示

In the first test case, if you place one bag at a time, the scale always shows 32=93^2 = 9 (kilograms), so you cannot distinguish any of them. However, if you place two bags at a time, only the combination 15+1715 + 17 yields 33=273^3 = 27 (kilograms). Therefore, the bag not placed on the scale at that moment must be the one labeled 11 (99 kilograms). Since the bags labeled 22 and 33 cannot be distinguished by any sequence of weighings, the maximum probability is 12\frac{1}{2}.

:::align{center} :::