logo AlgoBeat OnlineJudge
登录 注册

#217059. [NWERC 2022] Interview Question

内存限制:512 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Fizz Buzz is a party game that is often used as a programming exercise in job interviews. In the game, there are two positive integers and , and the game consists of counting up through the positive integers, replacing any number by Fizz if it is a multiple of , by Buzz if it is a multiple of , and by FizzBuzz if it is a multiple of both and . The most common form of the game has and , but other parameters are allowed.

Your task here is to solve the reverse problem: given a transcript of part of the game, not necessarily starting at , find possible values of and that could have been used to generate it.

The original statement shows some sample sequences for various values of and .

:::align{center} :::

Figure: Fizz Buzz implemented in Hexagony.

输入格式

The input consists of:

  • One line with two integers and (), indicating that your transcript starts at and ends at .
  • One line with integers and strings, the contents of the transcript.

It is guaranteed that the transcript is valid for some integers and with , according to the rules laid out above.

输出格式

Output two positive integers and () that are consistent with the given transcript.

If there are multiple valid solutions, you may output any one of them.

样例

样例输入 1

7 11
7 8 Fizz Buzz 11

样例输出 1

3 5

样例输入 2

49999 50002
49999 FizzBuzz 50001 Fizz

样例输出 2

2 125

样例输入 3

8 11
Buzz Buzz FizzBuzz Buzz

样例输出 3

10 1 

样例输入 4

10 15
10 11 12 13 14 15

样例输出 4

8 23