#P16784. [蓝桥杯 2026 国 A] 圆形灯环
[蓝桥杯 2026 国 A] 圆形灯环
Problem Description
Xiao Lan bought a smart circular light ring. The ring consists of LED beads connected end to end, arranged in clockwise order.
Each bead can be independently set to one of different brightness levels, labeled from to .
To prevent damage caused by unstable current, the overall brightness configuration of the ring must be in a stable state. A “stable” configuration must satisfy both of the following conditions:
- In the clockwise direction, for any consecutive beads, the sum of their brightness levels must not be equal to .
- In the clockwise direction, the total number of occurrences of the adjacent pair with brightness levels then (that is, the previous bead is level and the next bead is level ) across the entire ring must be even.
In addition, due to the closed nature of the ring, the last bead and the first bead are also adjacent (for example, if the tail is level and the head is level , it is counted in the number of occurrences of the above pair as usual).
Also, since the ring can rotate freely, any configurations that can coincide with each other by a clockwise rotation (i.e., a cyclic shift) are considered essentially the same solution.
Now, help Xiao Lan compute how many essentially different stable brightness configurations there are. Since the final number may be very large, output it modulo .
Output Format
This is an output-only fill-in-the-blank problem. You only need to compute the result and submit it. The answer is an integer. When submitting, you only need to write a program that outputs this integer. Any extra content will result in no score.
Hint
Translated by ChatGPT 5