Another FizzBuzz Task
면접 대비시간 제한2초메모리 제한512 MB
길이가 15 이하인 문자열이 무한 FizzBuzz 문자열 F의 부분 문자열로 등장하는지 판정하고, 등장하면 처음 나타나는 위치의 1-based 인덱스를 구합니다.
문제
Let us transform the sequence of positive integers 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 obtained by writing this sequence without spaces. Given a string , find whether it appears as substring of , and if it appears, find the 1-based index of first appearance.
입력
First line of the input contains one integer , the number of test cases (). Each of the next lines contains one non-empty string composed from digits and letters "F", "B", "i", "u", and "z". The length of this string does not exceed .
출력
For each test case, print if the given string does not appear in as a substring, or the smallest possible 1-based index of its first element in if it appears.