#C10042. Distinct Border and Inner Coloring Ways
Distinct Border and Inner Coloring Ways
Distinct Border and Inner Coloring Ways
In this problem, you are given a grid of size (n \times m) and (c) available colors. The task is to count the number of distinct ways to color the grid such that the border is colored uniformly with one color and the inner portion is colored uniformly with a different color. It is required that the border color and the inner color must be different. In other words, if (c) represents the total number of colors, then the number of valid colorings is given by the formula:
[ \text{ways} = c \times (c - 1) \quad \text{for } c \ge 2, ]
If (c < 2), it is impossible to satisfy the condition, and thus the answer is 0.
Note: Although the grid dimensions (n) and (m) are provided as input, they are not used in the computation of the answer.
inputFormat
Input contains a single line with three space-separated integers (n), (m), and (c).
outputFormat
Output a single integer representing the number of distinct ways to color the grid according to the given condition.## sample
3 4 5
20
</p>