Skip to content

Commit 3aa3cba

Browse files
committed
[BOJ]#16953. A->B/ 실버 1/25min
https://www.acmicpc.net/problem/16953
1 parent 04d24b0 commit 3aa3cba

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Hongjoo/백준/A2B.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""
2+
BOJ#16953. A-> B / Silver 1
3+
https://my-coding-notes.tistory.com/210
4+
"""
5+
from collections import deque
6+
a,b = map(int,input().split())
7+
q = deque()
8+
q.append((a,1))
9+
r = 0
10+
11+
while(q):
12+
n,t = q.popleft()
13+
if n > b:
14+
continue
15+
if n == b:
16+
print(t)
17+
break
18+
q.append((int(str(n)+"1"),t+1))
19+
q.append((n*2,t+1))
20+
else:
21+
print(-1)

0 commit comments

Comments
 (0)