luogu#P2490. [SDOI2011] 黑白棋

    ID: 6528 Type: RemoteJudge 1000ms 125MiB Tried: 4 Accepted: 3 Difficulty: 8 Uploaded By: Tags>博弈论排列组合递推各省省选2011山东

[SDOI2011] 黑白棋

Problem 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