#P1357. 花园

    ID: 354 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>动态规划,dp福建省历届夏令营矩阵运算状态压缩,状压

花园

Description

Xiao L has a circular garden. Number the flower plots from 11 to nn in the clockwise direction. Plots 11 and nn are adjacent.

His circular garden can have a new arrangement every day, but all arrangements must follow one rule: in any mm consecutive plots, there are at most kk plots of type "C", and all remaining plots are of type "P".

For example, if n=10n = 10, m=5m = 5, k=3k = 3, then:

  • CCPCPPPPCC is an arrangement that does not satisfy the rule.
  • CCPPPPCPCP is an arrangement that satisfies the rule.

Please compute the number of arrangements that satisfy the rule, modulo 109+710^9 + 7.

Input Format

One line containing three integers nn, mm, and kk.

Output Format

Output one line with a single integer, the answer.

10 5 3

458
6 2 1

18

Hint

Constraints

  • For 40%40\% of the testdata, n20n \le 20.
  • For 60%60\% of the testdata, m=2m = 2.
  • For 80%80\% of the testdata, n105n \le 10^5.
  • For 100%100\% of the testdata, 2n10152 \le n \le 10^{15}, 2mmin(n,5)2 \le m \le \min(n, 5), 1k<m1 \le k \lt m.

Translated by ChatGPT 5