← RoseCode

ROSECODE 549

Sum of the numbers with a fixed digit sum

C_K_Yang · Programming ·

Let F(B,L,D) be the sum of all the L-digit numbers in base B, the digit sum of which is D.

For example, F(3,3,3)=79. In base 3, there are five 3-digit numbers the digit sum of which is 3. The sum of these five numbers is 79. (102)3+(111)3+(120)3+(201)3+(210)3=(2221)3=(79)10

Now we define a new function S(B,L,N) = pN, p is primeF(B,L,p)

For example, S(5,5,11)=964140 and S(56,20,101)913761394(mod1000004321)

Find S(556678,999,12345701)mod1000004321

Note:Leading zeroes are not allowed for a L-digit number in base B.