QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 256 MB Points totaux : 100 Difficulté: [afficher]

#1064. Moving Coins

Statistiques

Initially, $m$ gold coins are placed on a $1 \times n$ chessboard. Each gold coin occupies a distinct cell, and there is at most one gold coin in any cell.

Alice and Bob play a game as follows. They take turns, with Alice going first. On their turn, a player can choose one gold coin and move it any number of cells to the left, provided it moves at least one cell. A gold coin cannot be moved off the board, nor can it jump over other gold coins.

If a player cannot make any valid move (which happens when the $m$ gold coins are exactly in the leftmost $m$ cells), they are declared the loser. Alice and Bob are both perfectly rational and will always make the optimal move in any situation. How many initial states guarantee that Alice will win?

Input

The input consists of a single line containing two positive integers $n$ and $m$, as described in the problem.

Output

Output a single integer representing the number of initial states that guarantee a win for Alice as the first player. Since the answer may be very large, output the result modulo $10^9 + 9$.

Examples

Input 1

10 3

Output 1

100

Input 2

199 43

Output 2

981535230

Input 3

99999 47

Output 3

39178973

Subtasks

Subtask 1: (50 points) $1 \le n \le 250$ and $1 \le m \le 50$.

Subtask 2: (50 points) $1 \le n \le 150000$ and $1 \le m \le 50$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.