[Solution] Circular Mirror Codeforces Solution
Pak Chanek has a mirror in the shape of a circle. There are lamps on the circumference numbered from to in clockwise order. The length of the arc from lamp to lamp is for . Meanwhile, the length of the arc between lamp and lamp is .
Pak Chanek wants to colour the lamps with different colours. Each lamp can be coloured with one of the colours. However, there cannot be three different lamps such that the colours of the three lamps are the same and the triangle made by considering the three lamps as vertices is a right triangle (triangle with one of its angles being exactly degrees).
The following are examples of lamp colouring configurations on the circular mirror.
Before colouring the lamps, Pak Chanek wants to know the number of distinct colouring configurations he can make. Count the number of distinct possible lamp colouring configurations, modulo .
The first line contains two integers and (, ) — the number of lamps in the mirror and the number of different colours used.
The second line contains integers () — the lengths of the arcs between the lamps in the mirror.
An integer representing the number of possible lamp colouring configurations, modulo .
In the first example, all correct lamp colouring configurations are , , , , , , , , , and .
No comments:
Post a Comment