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

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

Pea Pattern

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

요약
n에서 시작해 각 항을 자리 숫자별 개수로 다시 쓰는 과정을 반복하며, m이 처음 나타나는 위치를 찾거나 나타나지 않음을 판정한다.
난이도

보통10점 중 6점

유형
구현, 문자열, 시뮬레이션, 배열
정답자
아직 제출이 없습니다

문제

Do you see the pattern in the following sequence of numbers?

1,11,21,1112,3112,211213,312213,…1, 11, 21, 1112, 3112, 211213, 312213, \ldots

Each term describes the makeup of the previous term in the list. For example, the term 31123112 indicates that the previous term consisted of three 11's (that's the 3131 in 31123112) and one 22 (that's the 1212 in 31123112). The next term after 31123112 indicates that it contains two 11's, one 22 and one 33. This is an example of a pea pattern.

A pea pattern can start with any number. For example, if we start with the number 2090220902 the sequence would proceed 202219202219, 1011321910113219, 10411213191041121319, 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 101011213141516171829101011213141516171829 appears in the sequence starting with 2090220902. Well, this is your lucky day because you're about to find out.

입력

Input consists of a single line containing two positive integers nn and mm, where nn is the starting value for the sequence and mm is a target value. Both values will lie between 00 and 10100−110^{100}-1.

출력

If mm appears in the pea pattern that starts with nn, display its position in the list, where the initial value is in position 11. If mm does not appear in the sequence, display Does not appear. We believe that all of these patterns converge on a repeating sequence within 100100 numbers, but if you find a sequence with more than 100100 numbers in it, display I'm bored.

예제3

  1. 예제 1

    입력
    1 3112
    
    예상 출력
    5
    
  2. 예제 2

    입력
    1 3113
    
    예상 출력
    Does not appear
    
  3. 예제 3

    입력
    20902 101011213141516171829
    
    예상 출력
    10