- 발차기 방법에는 2가지 종류가 있다. 그에 맞추어 a 발차기는 s 2배, t 에 +3을 해준다. 둘다 하나의 횟수로 치기 때문에 횟수는 1씩 증가한다.
- 큐 안에 s, t, 발차기 횟수를 tuple의 형식으로 넣어준다. 발차기 종류가 2개이므로 2종류 모두 넣어준다.
- 메모리 : 32396 KB
- 시간 : 100 ms
from collections import deque
def bfs(s,t,cnt):
q = deque()
q.append((s,t,0))
while q:
s, t, cnt = q.popleft()
if s <= t:
q.append((s*2,t+3,cnt+1))
q.append((s+1,t,cnt+1))
if s == t:
return cnt
c = int(input())
while c:
c -= 1
s, t = tuple(map(int, input().split()))
print(bfs(s,t,0))
