본문 바로가기
Coding Test/Programmers

[Programmers] (2017 팁스타운) Lv 2. 예상 대진표

by song.ift 2023. 5. 31.

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 : https://github.com/developeSHG/Algorithm-Baekjoon_Programmers/blob/fe387e8e547e58ef9757702e5bd65267c3c36dfe/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4/lv2/12985.%E2%80%85%EC%98%88%EC%83%81%E2%80%85%EB%8C%80%EC%A7%84%ED%91%9C/%EC%98%88%EC%83%81%E2%80%85%EB%8C%80%EC%A7%84%ED%91%9C.cpp

 

GitHub - developeSHG/Algorithm-Baekjoon_Programmers: 백준 and 프로그래머스 소스코드

백준 and 프로그래머스 소스코드. Contribute to developeSHG/Algorithm-Baekjoon_Programmers development by creating an account on GitHub.

github.com

 

댓글