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

4271번 - Cousins 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB2000.000%

문제

Two strings a and b are defined to be first cousins if they can be made equal by removing no more than half the characters from each. For example "abcdef" and "axcyd" are first cousins because we can remove 3 of the 6 characters (b,e,f) from the first string and 2 of the 5 characters in the second string (x,y) resulting in "acd". Two strings c and d are said to be n+1st cousins if there exists a string e that is a first cousin of c and is an nth cousin of d.

Given two strings x and y, determine the smallest n ≥ 1 such that x is an nth cousin of y.

입력

Input consists of several test cases. Each test case consists of two lines representing x and y. x and y each consist of at least 1 and at most 100 lower case letters. Two lines containing 0 follow the last test case.

출력

For each test case, output a line containing n or not related if x and y are not nth cousins for any n.

제한

예제 입력 1

a
b
abb
baa
abcdef
axcyd
0
0

예제 출력 1

2
2
1

힌트

출처

Contest > Waterloo's local Programming Contests > 24 September, 2006 E번

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

출처

대학교 대회

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

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