CF1152F1.Neko Rules the Catniverse (Small Version)

省选/NOI-

通过率:0%

时间限制:7.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

This problem is same as the next one, but has smaller constraints.

Aki is playing a new video game. In the video game, he will control Neko, the giant cat, to fly between planets in the Catniverse.

There are nn planets in the Catniverse, numbered from 11 to nn. At the beginning of the game, Aki chooses the planet where Neko is initially located. Then Aki performs k−1k - 1 moves, where in each move Neko is moved from the current planet xx to some other planet yy such that:

  • Planet yy is not visited yet.
  • 1≤y≤x+m1 \leq y \leq x + m (where mm is a fixed constant given in the input)

This way, Neko will visit exactly kk different planets. Two ways of visiting planets are called different if there is some index ii such that the ii-th planet visited in the first way is different from the ii-th planet visited in the second way.

What is the total number of ways to visit kk planets this way? Since the answer can be quite large, print it modulo 109+710^9 + 7.

本题与下一题相同,但约束条件更小。

Aki 正在玩一款新视频游戏。在游戏中,他将操控巨型猫 Neko,在“猫宇宙”(Catniverse)中的各个行星之间飞行。

猫宇宙中共有 nn 颗行星,编号从 11 到 nn。游戏开始时,Aki 选择一颗行星作为 Neko 的初始位置。随后 Aki 执行 k−1k - 1 次移动操作;每次操作中,Neko 从当前所在行星 xx 移动到另一颗行星 yy,要求满足:

  • 行星 yy 尚未被访问过;
  • 1≤y≤x+m1 \leq y \leq x + m(其中 mm 是输入中给定的一个固定常数)。

如此一来,Neko 将恰好访问 kk 颗互不相同的行星。若两种行星访问序列在某个下标 ii 处所访问的第 ii 颗行星不同,则称这两种访问方式不同。

问:按上述规则访问 kk 颗行星的总方案数是多少?由于答案可能非常大,请输出其对 109+710^9 + 7 取模的结果。

输入格式

The only line contains three integers nn, kk and mm (1≤n≤1051 \le n \le 10^5, 1≤k≤min⁡(n,12)1 \le k \le \min(n, 12), 1≤m≤41 \le m \le 4) — the number of planets in the Catniverse, the number of planets Neko needs to visit and the said constant mm.

唯一的一行包含三个整数 nn、kk 和 mm(1≤n≤1051 \le n \le 10^5,1≤k≤min⁡(n,12)1 \le k \le \min(n, 12),1≤m≤41 \le m \le 4)——分别表示猫宇宙中的行星数量、Neko 需要访问的行星数量,以及给定的常数 mm。

输出格式

Print exactly one integer — the number of different ways Neko can visit exactly kk planets. Since the answer can be quite large, print it modulo 109+710^9 + 7.

输出一个整数——Neko 恰好访问 kk 个行星的不同方式数目。由于答案可能非常大,请对 109+710^9 + 7 取模后输出。

输入输出样例

  • 输入#1

    3 3 1

    输出#1

    4
  • 输入#2

    4 2 1

    输出#2

    9
  • 输入#3

    5 5 4

    输出#3

    120
  • 输入#4

    100 1 2

    输出#4

    100

说明/提示

In the first example, there are 44 ways Neko can visit all the planets:

  • 1→2→31 \rightarrow 2 \rightarrow 3
  • 2→3→12 \rightarrow 3 \rightarrow 1
  • 3→1→23 \rightarrow 1 \rightarrow 2
  • 3→2→13 \rightarrow 2 \rightarrow 1

In the second example, there are 99 ways Neko can visit exactly 22 planets:

  • 1→21 \rightarrow 2
  • 2→12 \rightarrow 1
  • 2→32 \rightarrow 3
  • 3→13 \rightarrow 1
  • 3→23 \rightarrow 2
  • 3→43 \rightarrow 4
  • 4→14 \rightarrow 1
  • 4→24 \rightarrow 2
  • 4→34 \rightarrow 3

In the third example, with m=4m = 4, Neko can visit all the planets in any order, so there are 5!=1205! = 120 ways Neko can visit all the planets.

In the fourth example, Neko only visit exactly 11 planet (which is also the planet he initially located), and there are 100100 ways to choose the starting planet for Neko.

在第一个例子中,Neko 访问所有行星的方式共有 44 种:

  • 1→2→31 \rightarrow 2 \rightarrow 3
  • 2→3→12 \rightarrow 3 \rightarrow 1
  • 3→1→23 \rightarrow 1 \rightarrow 2
  • 3→2→13 \rightarrow 2 \rightarrow 1

在第二个例子中,Neko 恰好访问 22 颗行星的方式共有 99 种:

  • 1→21 \rightarrow 2
  • 2→12 \rightarrow 1
  • 2→32 \rightarrow 3
  • 3→13 \rightarrow 1
  • 3→23 \rightarrow 2
  • 3→43 \rightarrow 4
  • 4→14 \rightarrow 1
  • 4→24 \rightarrow 2
  • 4→34 \rightarrow 3

在第三个例子中,当 m=4m = 4 时,Neko 可以以任意顺序访问所有行星,因此 Neko 访问所有行星的方式共有 5!=1205! = 120 种。

在第四个例子中,Neko 仅恰好访问 11 颗行星(即其初始所在行星),而为 Neko 选择起始行星的方式共有 100100 种。

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

首页