프로그래머스 - 예상대진표 (python)

먼지감자·2021년 7월 1일
0

코딩테스트

목록 보기
32/37

문제

https://programmers.co.kr/learn/courses/30/lessons/12985

코드

import math
def solution(n,a,b):
    answer = 0
    while a!= b:
        a = (a+1)//2
        b = (b+1)//2
        answer+=1
    return answer

설명

n이 2의 제곱수이기 때문에 a와 b가 얼마나 떨어져 있는지를 2로 나누어 가며 같아질때 까지 반복하면 a,b가 만나는 라운드가 나옴

profile
ML/AI Engineer

0개의 댓글