Preparando MOJI

Number of Binominal Coefficients

4000ms 262144K

Description:

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.

Input:

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.

Output:

In the single line print the answer to the problem.

Sample Input:

2 2
7

Sample Output:

3

Sample Input:

3 1
9

Sample Output:

17

Sample Input:

3 3
9

Sample Output:

0

Sample Input:

2 4
5000

Sample Output:

8576851

Note:

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

Informação

Codeforces

Provedor Codeforces

Código CF582D

Tags

dpmathnumber theory

Submetido 0

BOUA! 0

Taxa de BOUA's 0%

Datas 09/05/2023 09:00:25

Relacionados

Nada ainda