https://school.programmers.co.kr/learn/courses/30/lessons/12985
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
class Command
{
public:
Command(const int& a, const int& b)
: _a(a), _b(b)
{
}
const bool operator() ()
{
return _a != _b;
}
public:
void vs()
{
_a = (_a + 1) >> 1;
_b = (_b + 1) >> 1;
}
private:
int _a;
int _b;
};
int solution(int n, int a, int b)
{
int answer = 0;
Command cmd(a, b);
while (cmd())
{
cmd.vs();
++answer;
}
return answer;
}
GitHub - developeSHG/Algorithm-Baekjoon_Programmers: 백준 and 프로그래머스 소스코드
백준 and 프로그래머스 소스코드. Contribute to developeSHG/Algorithm-Baekjoon_Programmers development by creating an account on GitHub.
github.com
'Coding Test > Programmers' 카테고리의 다른 글
[Programmers] Lv 2. N개의 최소공배수 (0) | 2023.06.01 |
---|---|
[Programmers] (Summer/Winter Coding(~2018)) Lv 2. 점프와 순간 이동 (0) | 2023.05.31 |
[Programmers] (탐욕법(Greedy)) Lv 2. 구명보트 (0) | 2023.05.30 |
[Programmers] (완전탐색) Lv 2. 카펫 (0) | 2023.05.25 |
[Programmers] Summer/Winter Coding(~2018) Lv 2. 영어 끝말잇기 (0) | 2023.05.23 |
댓글