[CSP-S Simulation Test]: Password (Digital DP + Kummer theorem)

Title Description

In order to debunk $ SERN $ plot, $ Itaru $ $ SERN $ black into the network system.
However, they want complete control over $ SERN $, also need to know the administrator password. $ $ Itaru found from the intercepted message, administrator password $ $ SERN two integers $ l, s, 0 \ leqslant s \ leqslant l $, and that once the administrator password, you can generate a $ SERN $ each network interface password: password each network interface are a plurality of length $ L $ 0 $ / $ 1 strings, and each string number is just $ 1 to $ $ s $. Difficult to find, the number of generated code string is a number of combinations.
$ $ SERN network system by $ p ^ k $ configured network interfaces, $ $ SERN To ensure the stability of the network system, to ensure that the $ $ p is a prime number, password and the number of all strings that can be generated $ p ^ k $ divisible. In order to facilitate network communications, $ SERN $ network password interface will not be too long, which can guarantee $ l \ leqslant N $.
As a $ Super \ Hacker $, $ Itaru $ 've thought an excellent way to crack the code, but before that, he might need to confirm how many cases the administrator password. Since the answer may be large, the answer modulo $ ^ {10} $ 9 + 7.


Input Format

A line containing only three integers $ N, p, k $.


Output Format

It contains only one integer that represents the answer.


Sample

Sample input:

4 2 2

Sample output:

2


Data range and tips

Sample explained:

There $ 2 $ possible case, $ l = 4, s = 1; l = 4s = 3 $.

data range:

Guaranteed $ 1 \ leqslant p, k \ leqslant {10} ^ 9,1 \ leqslant N \ leqslant {10} ^ {1000} $, $ p $ is a prime number.
Each test point further satisfies the following constraints:


answer

Is math, then of the equation.

The number of combinations and related factorial, we can consider factorial.
!! For $ n $, satisfying $ p ^ k | n $ $ k $ maximum is: $$ maxk = \ sum \ limits_ {i = 1} ^ {\ infty} \ left \ lfloor \ frac {n} {p ^ i} \ right \ rfloor $$
then for $ C_n ^ m $, since $ C_n ^ m = \ frac { m (nm)!!} $, satisfy $ p ^ k {n!} | C_n ^ m $ $ k $ maximum is: $$ maxk = \ sum \ limits_ {i = 1} ^ {\ infty} \ left \ lfloor \ frac {n} {p ^ i} \ right \ rfloor- \ left \ lfloor \ frac {m} {p ^ i} \ right \ rfloor- \ left \ lfloor \ frac {nm} {p ^ i} \ right \ rfloor \ left \ lfloor \ frac {nm} {p ^ i} \ right \ rfloor $$

Then we introduce a new term: Kummer theorem.

So, what is the theorem of Kummer it?

Set $ ​​m, n $ is a positive integer, $ p $ is a prime, then $ C_ {m + n} ^ m $ containing $ p $ the power of equal to $ m + n $ binary number at $ p $ hexadecimal .

Proof is given below:

组合数:$$C_{n+m}^m$$
所含$p$的幂次数为:$$\sum \limits_{i=1}^{\infty}\left \lfloor \frac{m+n}{p^i}\right \rfloor-\sum \limits_{i=1}^{\infty}\left \lfloor \frac{n}{p^i}\right \rfloor-\sum \limits_{i=1}^{\infty}\left \lfloor \frac{m}{p^i}\right \rfloor$$
$$=\sum \limits_{i=1}^{\infty}(\left \lfloor \frac{m+n}{p^i}\right \rfloor-\left \lfloor \frac{n}{p^i}\right \rfloor-\left \lfloor \frac{m}{p^i}\right \rfloor)$$

Guess you like

Origin www.cnblogs.com/wzc521/p/11548364.html