#2550

Count Collisions of Monkeys on a Polygon

expert · 1175 · lc medium +32 · 30% accepted · 268 likes · top 7%

Description

On a regular convex polygon with n vertices (labeled 0 to n - 1 clockwise), each vertex holds exactly one monkey. All monkeys simultaneously move to a neighboring vertex. Return the number of movement combinations that result in at least one collision (two monkeys on the same vertex or crossing the same edge), modulo 109 + 7.

Code

1
2
3