#P12181. DerrickLo's Buildings (UBC002D)
DerrickLo's Buildings (UBC002D)
Description
In a game, DerrickLo needs to complete a task of managing a bunch of buildings. These buildings are placed on position to . Their heights are to , too. Initially, the building with height is placed on position , for each from to .
There are also challenges, the -th challenge contains a height factor and a target length . The score of this challenge is the number of from to such that the building with height is placed on position after rearranging the positions of the buildings. Note that the target lengths of each challenge are the same, but the height factors are distinct.
To rearrange the buildings, DerrickLo needs to give a shift permutation . Whenever he shifts, he moves the building on position to position for each from to simultaneously.
Since DerrickLo is not interested in whether he achieved the maximum score, the shift permutation is chosen uniformly from all permutations of . However, he is curious that for each challenge , what is the expected score if he shifts times separately.
Because the number of challenges and shifts are too big, DerrickLo wants you to calculate the sum of the expected scores modulo , that is,
$$\left(\sum_{i=1}^M\sum_{k=1}^VE\left(\sum_{j=1}^N[v_k(j) = i \times j]\right)\right) \bmod 998244353$$where is the position of building with height after shifting times based on the shift permutation .
Input Format
This problem has multiple testcases.
The first line contains an integer , the number of testcases.
The following lines, each contains three integers , which discribes a testcase.
Note that the input data may NOT fit into a 32-bit integer.
Output Format
lines, each represents an answer to a testcase in given order.
1
1 2 1
1
Hint
In the sample, is either or . You need to calculate:
When , . When , . Thus, the sum is .
For all testcases:
- .
- .
- .
- .
Note that the input data may NOT fit into a 32-bit integer.
京公网安备 11011102002149号