Problem B
Interview Question
CC BY-SA 3.0 by M L on codegolf.stackexchange.com
Your task here is to solve the reverse problem: given a transcript of part of the game (not necessarily starting at 1), find possible values of $a$ and $b$ that could have been used to generate it.
Figure 1 shows some sample sequences for various values of $a$ and $b$.
$a=3, b=5:$ |
1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz |
$a=6, b=2:$ |
1 Buzz 3 Buzz 5 FizzBuzz 7 Buzz 9 Buzz 11 FizzBuzz 13 |
$a=4, b=4:$ |
1 2 3 FizzBuzz 5 6 7 FizzBuzz 9 10 11 FizzBuzz 13 14 |
Input
The input consists of:
-
One line with two integers $c$ and $d$ ($1 \le c \le d \le 10^5$), indicating that your transcript starts at $c$ and ends at $d$.
-
One line with $d-c+1$ integers and strings, the contents of the transcript.
It is guaranteed that the transcript is valid for some integers $a$ and $b$ with $1 \le a,b \le 10^6$, according to the rules laid out above.
Output
Output two positive integers $a$ and $b$ ($1 \le a,b \le 10^6$) that are consistent with the given transcript.
If there are multiple valid solutions, you may output any one of them.
Sample Input 1 | Sample Output 1 |
---|---|
7 11 7 8 Fizz Buzz 11 |
3 5 |
Sample Input 2 | Sample Output 2 |
---|---|
49999 50002 49999 FizzBuzz 50001 Fizz |
2 125 |
Sample Input 3 | Sample Output 3 |
---|---|
8 11 Buzz Buzz FizzBuzz Buzz |
10 1 |
Sample Input 4 | Sample Output 4 |
---|---|
10 15 10 11 12 13 14 15 |
8 23 |