그냥 시뮬레이션 문제같다.
어려운것 없이 조건에 맞춰 구현하면 되었다.
#include <iostream>
using namespace std;
int solution(int n, int a, int b)
{
int answer = 1;
while (1)
{
if (a % 2 == 1)
a++;
if (b % 2 == 1)
b++;
if (a / 2 == b / 2)
break;
a /= 2;
b /= 2;
answer++;
}
return answer;
}'Coding_Test 연습 > Programmers' 카테고리의 다른 글
| [프로그래머스] (C++) LV2 배달 (0) | 2022.05.25 |
|---|---|
| [프로그래머스] (C++) LV2 괄호 회전하기 (0) | 2022.05.25 |
| [프로그래머스] (C++) LV2 게임 맵 최단거리 (0) | 2022.05.24 |
| [프로그래머스] (C++) LV2 조이스틱 (0) | 2022.05.23 |
| [프로그래머스] (C++) LV2 소수 찾기 (0) | 2022.05.23 |