#P4007. Expected Boss Damage

    ID: 17255 Type: Default 1000ms 256MiB

Expected Boss Damage

Expected Boss Damage

Little Y is an OIer who loves games. One day she plays a game in which she has to fight a boss. The boss has \(10^{100}\) hit points, but it carries only one minion – a terrifying slave-master with \(m\) hit points.

This slave-master has a special ability. Whenever it is attacked and loses 1 hit point but does not die (i.e. its hit points remain \(> 0\)), and at that moment the total number of alive slave-masters is less than an upper limit \(k\), it immediately summons a new slave-master with \(m\) hit points.

Little Y can launch \(n\) attacks. In each attack, one entity is chosen uniformly at random among the boss and all alive slave-masters, and that entity loses 1 hit point. The boss, having absurdly huge hit points, will never die. Your task is to compute the expected total number of hit points reduced from the boss after \(n\) attacks. Since the answer may be a rational number, output it modulo \(998244353\). (All divisions should be performed modulo \(998244353\) using the modular inverse.)

Note: When a slave-master's hit points drop from \(r\) to \(r-1\) and \(r-1>0\), the summoning occurs only if the current count of alive slave-masters is less than \(k\). If the slave-master is attacked with \(r=1\), it dies and no summoning occurs. Once a slave-master dies it is removed from the field and will no longer be chosen in subsequent attacks.

inputFormat

The input consists of a single line containing three integers \(n\), \(m\), and \(k\), where:

  • \(n\) is the number of attacks,
  • \(m\) is the initial hit points of each slave-master,
  • \(k\) is the maximum allowed number of slave-masters at any time.

It is guaranteed that the values of \(n\), \(m\), and \(k\) are such that a reasonable simulation or dynamic programming solution will work.

outputFormat

Output a single integer, the expected number of hit points reduced from the boss after \(n\) attacks, taken modulo \(998244353\).

sample

3 2 2
499122180