Pirouettes
Time limit1sMemory limit1024 MB
Count the ways to place K obstacles on the 2N free cells of a room so that a ballerina starting at 0 and taking T unit steps is back at 0.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Combinatorics, Simulation
- Solved
- No attempts yet
Problem

Given an integer , consider a room of length , represented as the interval . At the center of the room, a ballerina called Costelina Salopeta starts. She performs dancing steps of length . The first step goes to the right. The room has integer coordinates where you can place obstacles. When the ballerina reaches an obstacle, she trips and performs a pirouette. She then reverses her moving direction, and the obstacle disappears.
You may not place an obstacle at coordinates , , or . The walls at and are permanent obstacles that never disappear. The point is Costelina's starting position.
Given , , and , count the ways to place obstacles so that Costelina is back at the starting point after steps.
Input
The first line contains three integers , and .
Output
Output a single integer, the answer modulo .
Constraints
- , is even