아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Interview Question

시간 제한1초메모리 제한1024 MB

요약
c부터 d까지 진행한 Fizz Buzz 경기의 기록이 주어질 때, 이 기록을 만들 수 있는 a와 b의 쌍을 아무거나 하나 출력한다.
난이도

보통10점 중 5점

유형
수학, 정수론, 완전 탐색, 구현
정답자
아직 제출이 없습니다

문제

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

Figure I.1 shows some sample sequences for various values of aa and bb.

a=3,b=5:a=3, b=5:1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz
a=6,b=2:a=6, b=2:1 Buzz 3 Buzz 5 FizzBuzz 7 Buzz 9 Buzz 11 FizzBuzz 13
a=4,b=4: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 cc and dd (1≤c≤d≤1051 \le c \le d \le 10^5), indicating that your transcript starts at cc and ends at dd.
  • One line with d−c+1d-c+1 integers and strings, the contents of the transcript.

It is guaranteed that the transcript is valid for some integers aa and bb with 1≤a,b≤1061 \le a,b \le 10^6, according to the rules laid out above.

출력

Output two positive integers aa and bb (1≤a,b≤1061 \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.

예제4

  1. 예제 1

    입력
    7 11
    7 8 Fizz Buzz 11
    
    예상 출력
    3 5
    
  2. 예제 2

    입력
    49999 50002
    49999 FizzBuzz 50001 Fizz
    
    예상 출력
    2 125
    
  3. 예제 3

    입력
    8 11
    Buzz Buzz FizzBuzz Buzz
    
    예상 출력
    10 1
    
  4. 예제 4

    입력
    10 15
    10 11 12 13 14 15
    
    예상 출력
    8 23