#P2490. [SDOI2011] 黑白棋

    ID: 1504 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>动态规划,dp递推博弈论2011各省省选山东排列组合

[SDOI2011] 黑白棋

Description

A and B came up with a new game.

The game is played on a 1×n1 \times n board. There are kk pieces on the board, half black and half white.

The leftmost piece is white, the rightmost piece is black, and adjacent pieces have alternating colors.

A may move white pieces, and B may move black pieces. White pieces cannot move left, and black pieces cannot move right. On each turn, they may move 11 to dd pieces.

When moving a piece, it cannot cross over neighboring pieces on either side, and it cannot move off the board. Whoever has no legal move loses.

A and B take turns, with A moving first. How many initial arrangements of the pieces will make A win?

Input Format

Input three numbers n,k,dn,k,d.

Output Format

Output the total number of initial configurations in which A wins. Print the answer modulo 109+710^9+7.

10 4 2
182

Hint

  • For 30%30\% of the testdata, k=2k=2.
  • For 100%100\% of the testdata, 1dkn1041 \leq d \leq k \leq n \leq 10^4, kk is even, and k100k \leq 100.

Translated by ChatGPT 5