Problem Statement
题目简述
我们作出如下递归定义:
f[n][k] = f[n][k-1] * f[n-1][k] (n>0,k>0)
f[n][k] = 1 (n=0)
f[n][k] = n (k=0)
给出N,K,B,求f[N][K]在B进制下末尾0的个数,答案对10^9+9取模。
1 <= N <= 10^9,1 <= K <= 16,2 <= B <= 10
The factorial of the k-th order of a number n is denoted n!k and defined by the following recurrences:
1) n!k = n!(k-1) * (n-1)!k for n > 0 and k > 0
2) n!k = 1 for n = 0
3) n!k = n for k = 0
For example, 7!1 = 7! (the traditional factorial), and 5!3 = 5!2 * 4!3 = (5!1 * 4!2) * 4!3.
You are given ints N, K and B. Count the number of trailing zeros in the number N!K when it is written in base B and return it modulo 1,000,000,009.