Pea Pattern
시간 제한1초메모리 제한1024 MB
n에서 시작해 각 항을 자리 숫자별 개수로 다시 쓰는 과정을 반복하며, m이 처음 나타나는 위치를 찾거나 나타나지 않음을 판정한다.
문제
Do you see the pattern in the following sequence of numbers?
Each term describes the makeup of the previous term in the list. For example, the term indicates that the previous term consisted of three 's (that's the in ) and one (that's the in ). The next term after indicates that it contains two 's, one and one . This is an example of a pea pattern.
A pea pattern can start with any number. For example, if we start with the number the sequence would proceed , , , and so on. Note that digits with no occurrences in the previous number are skipped in the next element of the sequence.
We know what you're thinking. You're wondering if appears in the sequence starting with . Well, this is your lucky day because you're about to find out.
입력
Input consists of a single line containing two positive integers and , where is the starting value for the sequence and is a target value. Both values will lie between and .
출력
If appears in the pea pattern that starts with , display its position in the list, where the initial value is in position . If does not appear in the sequence, display Does not appear. We believe that all of these patterns converge on a repeating sequence within numbers, but if you find a sequence with more than numbers in it, display I'm bored.