Skip to content

Instantly share code, notes, and snippets.

@asukaminato0721
Created August 26, 2021 16:44
Show Gist options
  • Save asukaminato0721/b7c5a06016e21b8d10b2f0e963507a8e to your computer and use it in GitHub Desktop.
Save asukaminato0721/b7c5a06016e21b8d10b2f0e963507a8e to your computer and use it in GitHub Desktop.
英特尔 2016 软件类研发在线测评 13
def bfs(t: int):
vis = set()
q = [1]
level = 0
while q:
for _ in range(len(q)):
t = q.pop(0)
if t == 2013:
return level
for j in [t + 1, t * 2]:
if j not in vis:
vis.add(j)
q.append(j)
level += 1
print(bfs(1)) # 18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment