Logo
(追記) (追記ここまで)

26182번 - Interview Question 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB109817473.267%

문제

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 $a$ and $b,ドル and the game consists of counting up through the positive integers, replacing any number by Fizz if it is a multiple of $a,ドル by Buzz if it is a multiple of $b,ドル and by FizzBuzz if it is a multiple of both $a$ and $b$. The most common form of the game has $a=3$ and $b=5,ドル 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 1), find possible values of $a$ and $b$ that could have been used to generate it.

Figure I.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

Figure I.1: Example sequences for Fizz Buzz.

입력

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 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.

제한

예제 입력 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

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > NWERC 2022 I번

  • 문제를 만든 사람: Paul Wild
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /