Sequence
InterviewTime limit1sMemory limit128 MB
Given up to five strictly increasing numbers, find the smallest base at most 10 in which their values, read as base-b numerals, form an arithmetic sequence.
- Level
Easy3 of 10
- Topics
- Math, Brute force
- Solved
- No attempts yet
Problem
We call a sequence of numbers an arithmetic sequence in base if, when each number is read as a base- numeral, consecutive terms differ by a constant.
For example, is an arithmetic sequence in base , and is an arithmetic sequence not only in base but also in base .
Given a sequence of numbers, find the smallest base (at most ) in which the numbers form an arithmetic sequence.
If the largest digit appearing in any number is , then the base must be at least for every digit to be valid, and it is always at least .
Input
The input consists of several test cases.
The first line of each test case contains an integer (), the count of numbers in the sequence. The next line contains the numbers in strictly increasing order, separated by single spaces.
A line containing terminates the input. Every number is positive, uses only the digits through , and has at most digits.
Output
For each test case, print a single line.
If such a base exists, print
Minimum base = x.
where is the smallest base that yields an arithmetic sequence. Otherwise, print
No base <= 10 can be found.