CF582D.Number of Binominal Coefficients

NOI/NOI+/CTSC

通过率:0%

时间限制:4.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

For a given prime integer p and integers α, A calculate the number of pairs of integers (n, k), such that 0 ≤ k ≤ n ≤ A and is divisible by _p_α.

As the answer can be rather large, print the remainder of the answer moduly 109 + 7.

Let us remind you that is the number of ways k objects can be chosen from the set of n objects.

给定一个素数 $ p $ 以及整数 $ \alpha 、、 A $,请计算满足 $ 0 \leq k \leq n \leq A $ 且组合数

能被 $ p^\alpha $ 整除的整数对 $ (n, k) $ 的个数。

由于答案可能非常大,请输出答案对 $ 10^9 + 7 $ 取模的结果。

提醒:

表示从 $ n $ 个不同物体中选出 $ k $ 个物体的方法数(即二项式系数)。

输入格式

The first line contains two integers, p and α (1 ≤ p, α ≤ 109, p is prime).

The second line contains the decimal record of integer A (0 ≤ A < 101000) without leading zeroes.

第一行包含两个整数 pp 和 α\alpha(1≤p,α≤1091 \leq p, \alpha \leq 10^9,且 pp 为质数)。

第二行包含整数 AA 的十进制表示(0≤A<1010000 \leq A < 10^{1000}),不含前导零。

输出格式

In the single line print the answer to the problem.

在单行中输出问题的答案。

输入输出样例

  • 输入#1

    2 2
    7

    输出#1

    3
  • 输入#2

    3 1
    9

    输出#2

    17
  • 输入#3

    3 3
    9

    输出#3

    0
  • 输入#4

    2 4
    5000

    输出#4

    8576851

说明/提示

In the first sample three binominal coefficients divisible by 4 are , and .

在第一个样例中,有三个能被 4 整除的二项式系数:、 和 。

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

首页