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

19029번 - Another FizzBuzz Task 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB127444.444%

문제

Let us transform the sequence of positive integers 1,ドル 2, 3, \ldots$ in the following way:

  • if an integer is divisible by 15, it is replaced with "FizzBuzz",
  • if an integer is divisible by 3 and is not yet replaced, it is replaced with "Fizz",
  • if an integer is divisible by 5 and is not yet replaced, it is replaced with "Buzz"
  • otherwise the integer is not replaced.

The beginning of the sequence will look as follows:

1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 17 Fizz ...

Consider the infinite string $F$ obtained by writing this sequence without spaces. Given a string $L,ドル find whether it appears as substring of $F,ドル and if it appears, find the 1-based index of first appearance.

입력

First line of the input contains one integer $N,ドル the number of test cases (1ドル \le N \le 20$). Each of the next $N$ lines contains one non-empty string $L$ composed from digits and letters "F", "B", "i", "u", and "z". The length of this string does not exceed 15ドル$.

출력

For each test case, print $-1$ if the given string $L$ does not appear in $F$ as a substring, or the smallest possible 1-based index of its first element in $F$ if it appears.

제한

예제 입력 1

6
1
78Fizz
68FizzBuzz71
FizzBu
uzzBuz
987654321

예제 출력 1

1
16
208
18
-1
8358189296

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2018 > Day 9: Japanese+ Selection A번

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

출처

대학교 대회

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

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