Road Construction
Time limit2sMemory limit512 MB
Count the ways to place exactly M undirected edges among N houses, each edge joining houses at distance at most K, so that every house has even degree, modulo 1e9+7.
- Level
Hard8 of 10
- Topics
- Dynamic programming, Combinatorics, Graph, Bit manipulation
- Solved
- No attempts yet
Problem
Yeongseon lives in a city with houses, numbered 1 to . The city has no roads at the moment. Yeongseon wants to build exactly two-way roads between houses while keeping both rules below.
- Two different houses and can be joined by a road only when . Two houses joined by a road are adjacent. Several roads can join the same pair of houses.
- Every house must be adjacent to an even number of roads.
Two plans count as different when some pair of houses is joined by a different number of roads. Given , and , write a program that counts the plans for building the roads.
Input
The first line contains , and . (, , )
Output
Print the number of plans for building the roads, modulo 1,000,000,007, on the first line.
Hint
The picture below shows one way to build the roads in the first example.

The picture below shows one way to build the roads in the second example.
