跳到主要内容
图灵 OJTURING / ONLINE JUDGE

#F1545. Number of Binominal Coefficients

  • ID: 1551
  • 传统题
  • 2000ms
  • 256MiB
  • 尝试: 0
  • AC · 已通过: 0
  • 教学难度:挑战
  • 上传者:
  • 动态规划
  • 数学
  • 数论
  • 挑战
  • 难度
  • 共享题库
  • Codeforces
  • 英文题面
  • 题目来源
  • 题面语言

Number of Binominal Coefficients

题目描述

D. Number of Binominal Coefficients
time limit per test
4 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

Examples
Input
2 2
7
Output
3
Input
3 1
9
Output
17
Input
3 3
9
Output
0
Input
2 4
5000
Output
8576851
Note

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


题目来源:fps-www.educg.net-codeforce-1-2833.xml.zip;FPS 共享题包,题包内第 1064 题。保留原作者与原赛事署名。