CF431C.k-Tree

普及/提高-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.

A k-tree is an infinite rooted tree where:

  • each vertex has exactly k children;
  • each edge has some weight;
  • if we look at the edges that goes from some vertex to its children (exactly k edges), then their weights will equal 1, 2, 3, ..., k.

The picture below shows a part of a 3-tree.

As soon as Dima, a good friend of Lesha, found out about the tree, he immediately wondered: "How many paths of total weight n (the sum of all weights of the edges in the path) are there, starting from the root of a k-tree and also containing at least one edge of weight at least d?".

Help Dima find an answer to his question. As the number of ways can be rather large, print it modulo 1000000007 (109 + 7).

就在不久前,一位富有创造力的学生莱沙(Lesha)听了一堂关于树的课程。课后,莱沙受到启发,构思出了一种他称之为 k-树 的树结构。

k-树 是一棵无限的有根树,满足以下条件:

  • 每个顶点恰好有 kk 个子节点;
  • 每条边都具有某个权值;
  • 若考察从某一顶点出发指向其所有子节点的边(共 kk 条),则这些边的权值依次为 1, 2, 3, …, k1,\,2,\,3,\,\dots,\,k。

下图展示了一棵 3-树的一部分。

当莱沙的好朋友迪马(Dima)得知这种树后,他立刻想到一个问题:“在 k-树中,从根节点出发、总权值(即路径上所有边的权值之和)恰好为 nn,且路径中至少包含一条权值不小于 dd 的边的路径,一共有多少条?”

请帮助迪马回答这个问题。由于方案数可能非常大,请将结果对 10000000071000000007(即 109+710^9 + 7)取模后输出。

输入格式

A single line contains three space-separated integers: n, k and d (1 ≤ n, k ≤ 100; 1 ≤ d ≤ k).

一行包含三个以空格分隔的整数:nn、kk 和 dd(1 ≤ n, k ≤ 1001 ≤ n, k ≤ 100;1 ≤ d ≤ k1 ≤ d ≤ k)。

输出格式

Print a single integer — the answer to the problem modulo 1000000007 (109 + 7).

输出一个整数——该问题答案对 10000000071000000007(即 109+710^9 + 7)取模的结果。

输入输出样例

  • 输入#1

    3 3 2

    输出#1

    3
  • 输入#2

    3 3 3

    输出#2

    1
  • 输入#3

    4 3 2

    输出#3

    6
  • 输入#4

    4 5 2

    输出#4

    7

输入解题思路,AI测评打分。不知道怎么写?

首页