250x250
반응형
Notice
Recent Posts
Recent Comments
Link
목록예상 대진표 (1)
N

간단하게 풀 수 있는 문제다..! 우선 while문으로 계속 반복한다. a = (a / 2) + (a % 2) b = (b / 2) + (b % 2) 를 넣어주도록 한다. 그러면 이겼을 때 다음 라운드에서 받을 수 있는 차례가 나오게 된다. 만약 a와 b가 같다면 현재 라운드에서 만나는 것이므로 answer을 리턴해주면 끝..! #include using namespace std; int solution(int n, int a, int b) { int answer = 0; while(1) { a = (a / 2) + (a % 2); b = (b / 2) + (b % 2); answer++; if(a == b) return answer; } }
프로그래머스 알고리즘/2단계
2020. 5. 29. 10:43