#AS2201. Next Base(高级)

Next Base(高级)

Description

Given 3 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 2 and 16 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 10, 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 2 and 16 inclusive, and the starting value in the base given that will be no more than 16 digits long. We guarantee that ss is a valid number in base bb.

Output Format

For each set of 3 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.

Explanation

Example:

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 frequencies are:

  • Digit 1 occurs 9 times.
  • Digits 0, 2, 3, 4, 5, 6, 7 each occur 2 times.

The digit that occurs most frequently is 1, which occurs 9 times, so the output would be 9.

Sample Input / Output

15 8 2
9
25 2 1111011
105
20 12 9AB
14
10 16 ABCDEF
10
1000 2 1
4938