points marked points at coordinates 0, 1, ..., points − 1. Draw exactly pieces segments so that:
- each segment starts and ends at marked points and has non-zero length;
- no two segments overlap. Touching at an endpoint is allowed: [0, 2] and [2, 3] may be drawn together.
The segments do not have to cover every point. Two layouts are different if they differ in at least one segment.
Count the layouts. The number can be huge, so return it modulo 10⁹ + 7.points=4, pieces=1 → 6
A single segment is any pair of the four points: 4·3/2 = 6 ways.
points=3, pieces=2 → 1
The only option is [0, 1] and [1, 2], touching at point 1.
points=5, pieces=2 → 15
points=4, pieces=1
6
Run checks the first 3 tests in your browser. Submit checks all 61 tests on the server, hidden ones included.