[백준] A → B 16953번
두 숫자를 입력받은 후 while 반복, 조건문을 통해 cnt 출력
파이썬
import sys
input = sys.stdin.readline
n, m = map(int,input().split())
cnt = 1
while True:
if m == n:
break
elif (m % 2 != 0 and m % 10 !=1) or (m<n):
cnt = -1
break
else:
if m % 10 == 1:
m //= 10
cnt+=1
else:
m //=2
cnt+=1
print(cnt)
댓글남기기