#P9042. [PA 2021] Zbiory niezależne

[PA 2021] Zbiory niezależne

Problem Description

A tree T=(V,E)T = (V, E) is a simple undirected connected graph with no cycles. In this problem, we consider cc-colored trees, i.e., trees in which each node has one of cc colors.

Two colored trees T1=(V1,E1)T_1 = (V_1, E_1) and T2=(V2,E2)T_2 = (V_2, E_2) are equal if and only if:

  • There exists a bijection π:V1V2\pi : V_1 \to V_2 such that for any pair of nodes (u,v)V1(u, v) \in V_1, {u,v}E1\{u,v\} \in E_1 if and only if {π(u),π(v)}E2\{\pi(u), \pi(v)\} \in E_2.
  • For any node vV1v \in V_1, the color of node vv in T1T_1 is the same as the color of node π(v)\pi(v) in T2T_2.

We call an independent set of a tree T=(V,E)T = (V, E) any subset of nodes SVS \subseteq V such that no two different nodes in SS are connected by an edge. The size of an independent set SS is the number of nodes in SS.

Given three integers ll, rr, and cc, find how many different cc-colored trees have a maximum independent set size in [l,r][l, r]. Since the answer may be very large, output it modulo 998244353998244353.

Input Format

One line with three integers ll, rr, and cc.

Output Format

One line with one integer, the required value.

1 3 1
9
1 3 2
149

Hint

For 100%100\% of the testdata, 1lr5×1051 \leq l \leq r \leq 5 \times 10^5 and 1c9982443521 \leq c \leq 998244352.

Translated by ChatGPT 5