#C341. Wall Painting Arrangements
Wall Painting Arrangements
Wall Painting Arrangements
Given an integer \(n\) representing the number of sections in a wall and an integer \(k\) representing the number of available colors, determine the number of ways to paint the wall such that no two adjacent sections have the same color. The answer should be computed modulo \(10^9+7\).
The total number of valid painting arrangements is given by the formula:
\(\text{Total Ways} = k \times (k-1)^{n-1} \mod (10^9+7)\)
If there is only one section (\(n = 1\)), the number of ways is simply \(k\).
inputFormat
The input consists of a single line containing two space-separated integers \(n\) and \(k\).
outputFormat
Output a single integer: the number of valid painting arrangements modulo \(10^9+7\).
## sample1 2
2