#P2092. ACSL 2022-2023 Senior Division Contest #1 Next Base

ACSL 2022-2023 Senior 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 1616 inclusive. We guarantee that ss is a valid number in base bb. Find all of the digits in the numbers generated and print the number of times, in base 1010, that the most frequently found digit occurs.

INPUT FORMAT

There will be three values representing how many numbers to generate, the base to be used between 22 and 1616 inclusive, and the starting value in the base given that will be no more than 1616 digits long. We guarantee that ss is a valid number in base bb.

OUTPUT FORMAT

For each set of 33 input values, find how many times each digit occurs in the sequence of numbers generated. Then output the number of times the digit that is found the most actually occurs.

SAMPLE

INPUT #1

15 8 2

OUTPUT #1

9

INPUT #2

25 2 1111011

OUTPUT #2

105

INPUT #3

20 12 9AB

OUTPUT #3

14

INPUT #4

10 16 ABCDEF

OUTPUT #4

10

INPUT #5

1000 2 1

OUTPUT #5

4938

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 digit that occurs most frequently is 11 which occurs 99 times so the output would be 99.