CF582D.Number of Binominal Coefficients

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

For a given prime integer pp and integers α,Aα,A calculate the number of pairs of integers (n,k)(n,k) , such that 0<=k<=n<=A0<=k<=n<=A and is divisible by pαp^{α} .

As the answer can be rather large, print the remainder of the answer moduly 109+710^{9}+7 .

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

输入格式

The first line contains two integers, pp and αα ( 1<=p,α<=1091<=p,α<=10^{9} , pp is prime).

The second line contains the decimal record of integer AA ( 0<=A<10^{1000} ) without leading zeroes.

输出格式

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 .

首页