#P12181. Building Permutations and Expected Score

    ID: 14285 Type: Default 1000ms 256MiB

Building Permutations and Expected Score

Building Permutations and Expected Score

In this problem, you are given a game scenario where there are (M) buildings placed on positions numbered from (1) to (M) with heights (1) through (M) respectively; initially, the building of height (i) is located at position (i). There are exactly (M) challenges. In the (i)th challenge, a height factor (l = i) and a target length (N) are specified. After applying a permutation (v) repeatedly, the score for this challenge is defined as the number of indices (j) (with (1 \le j \le N)) such that the building of height (j) ends up at position (l \times j) (i.e. (v_k(j) = i \times j) after (k) applications of (v)). Here, (v_k) means applying the permutation (v) exactly (k) times. Notice that the target length (N) is identical for all challenges, although the height factors are distinct.\n\nDerrickLo chooses a permutation (v) uniformly at random from all permutations of ({1, 2, \dots, M}). For each challenge (with height factor (i)) and for each number of swap operations (k) from (1) to (V), you are to calculate the expected score. Finally, you need to output the sum of these expected scores modulo (998244353), i.e., compute: [ \left(\sum_{i=1}^M \sum_{k=1}^V E\Bigl(\sum_{j=1}^N \bigl[ v_k(j)= i \times j \bigr] \Bigr)\right) \bmod 998244353. ]
\nA key observation is that for any fixed building (i.e. a fixed (j)) and for any fixed number of operations (k), the position (v_k(j)) is uniformly distributed over ({1, 2, \dots, M}). Therefore, for a given challenge with height factor (i) and a building of height (j), the probability that (v_k(j) = i \times j) is (\frac{1}{M}) if (i \times j \le M) (and zero otherwise). Hence, the expected contribution from building (j) in challenge (i) is (\frac{1}{M}) if (i \times j \le M).\n\nThus, for each challenge (i) and for each operation count (k), the expected score is: [ E = \sum_{j=1}^N \frac{[i \times j \le M]}{M} = \frac{#{j ;:; 1 \le j \le N \text{ and } i \times j \le M}}{M}. ]
\nSumming over all challenges (i=1,2,\dots,M) and all swap counts (k=1,2,\dots,V) we get: [ \text{Answer} = \frac{V}{M} \sum_{i=1}^M \min\Bigl(N, \left\lfloor \frac{M}{i} \right\rfloor\Bigr) \bmod 998244353. ]
\nYour task is to compute this value given (M), (N), and (V).

inputFormat

The input consists of a single line containing three space‐separated integers (M), (N), and (V) representing the number of buildings (and challenges), the target length for each challenge, and the number of swap operations, respectively.

outputFormat

Output a single integer, the sum of the expected scores for all challenges and swap counts modulo (998244353).

sample

5 2 3
598946616