CF1152F2.Neko Rules the Catniverse (Large Version)

NOI/NOI+/CTSC

通过率:0%

时间限制:7.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

This problem is same as the previous one, but has larger 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≤1091 \le n \le 10^9, 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≤1091 \le n \le 10^9,1≤k≤min⁡(n,12)1 \le k \le \min(n, 12),1≤m≤41 \le m \le 4)——分别表示 Catniverse 中的行星数量、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 有 99 种方式恰好访问 22 颗行星:

  • 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 可以以任意顺序访问所有行星,因此共有 5!=1205! = 120 种方式访问所有行星。

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

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

首页