#P2088. ACSL 2022-2023 Intermediate Division Contest #1 Next Base

ACSL 2022-2023 Intermediate Division Contest #1 Next Base

PROBLEM DESCRIPTION

Given 33 positive integers, nn, bb, and ss, generate the next nn numbers in base bb starting with ss in the given base. We guarantee that the base will be between 22 and 99 inclusive. We guarantee that ss is a valid number in base bb. Find the base 1010 value for the number of times the largest possible digit in the given base is found among all of the digits in the numbers generated.

INPUT FORMAT

There will be three integers representing the number of values to be found, the base to be used between 22 and 99 inclusive, and the starting value in the base given that will be no more than 1616 digits.

OUTPUT FORMAT

For each set of 33 input values, output a base 1010 number representing the number of times the largest digit in the inputted base occurs in the sequence of numbers generated.

SAMPLE

INPUT #1

15 8 2

OUTPUT #1

2

INPUT #2

20 3 12

OUTPUT #2

21

INPUT #3

25 5 324

OUTPUT #3

24

INPUT #4

13 9 1652

OUTPUT #4

1

INPUT #5

45 2 1111011

OUTPUT #5

170

EXPLANATION

Sample #1 Explanation

If n=15n=15, b=8b=8, and s=2s=2, the numbers generated are $2, 3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15, 16, 17, 20$. The largest possible digit in base 88 is 77 which occurs 22 times.