|
| 1 | +# [level 2] 2개 이하로 다른 비트 - 77885 |
| 2 | + |
| 3 | +[문제 링크](https://school.programmers.co.kr/learn/courses/30/lessons/77885) |
| 4 | + |
| 5 | +### 성능 요약 |
| 6 | + |
| 7 | +메모리: 121 MB, 시간: 6.92 ms |
| 8 | + |
| 9 | +### 구분 |
| 10 | + |
| 11 | +코딩테스트 연습 > 월간 코드 챌린지 시즌2 |
| 12 | + |
| 13 | +### 채점결과 |
| 14 | + |
| 15 | +정확성: 100.0<br/>합계: 100.0 / 100.0 |
| 16 | + |
| 17 | +### 제출 일자 |
| 18 | + |
| 19 | +2025년 08월 06일 10:42:14 |
| 20 | + |
| 21 | +### 문제 설명 |
| 22 | + |
| 23 | +<p>양의 정수 <code>x</code>에 대한 함수 <code>f(x)</code>를 다음과 같이 정의합니다.</p> |
| 24 | + |
| 25 | +<ul> |
| 26 | +<li><code>x</code>보다 크고 <code>x</code>와 <strong>비트가 1~2개 다른</strong> 수들 중에서 제일 작은 수</li> |
| 27 | +</ul> |
| 28 | + |
| 29 | +<p>예를 들어, </p> |
| 30 | + |
| 31 | +<ul> |
| 32 | +<li><code>f(2) = 3</code> 입니다. 다음 표와 같이 2보다 큰 수들 중에서 비트가 다른 지점이 2개 이하이면서 제일 작은 수가 3이기 때문입니다.</li> |
| 33 | +</ul> |
| 34 | +<table class="table"> |
| 35 | + <thead><tr> |
| 36 | +<th>수</th> |
| 37 | +<th>비트</th> |
| 38 | +<th>다른 비트의 개수</th> |
| 39 | +</tr> |
| 40 | +</thead> |
| 41 | + <tbody><tr> |
| 42 | +<td>2</td> |
| 43 | +<td><code>000...0010</code></td> |
| 44 | +<td></td> |
| 45 | +</tr> |
| 46 | +<tr> |
| 47 | +<td>3</td> |
| 48 | +<td><code>000...0011</code></td> |
| 49 | +<td>1</td> |
| 50 | +</tr> |
| 51 | +</tbody> |
| 52 | + </table> |
| 53 | +<ul> |
| 54 | +<li><code>f(7) = 11</code> 입니다. 다음 표와 같이 7보다 큰 수들 중에서 비트가 다른 지점이 2개 이하이면서 제일 작은 수가 11이기 때문입니다.</li> |
| 55 | +</ul> |
| 56 | +<table class="table"> |
| 57 | + <thead><tr> |
| 58 | +<th>수</th> |
| 59 | +<th>비트</th> |
| 60 | +<th>다른 비트의 개수</th> |
| 61 | +</tr> |
| 62 | +</thead> |
| 63 | + <tbody><tr> |
| 64 | +<td>7</td> |
| 65 | +<td><code>000...0111</code></td> |
| 66 | +<td></td> |
| 67 | +</tr> |
| 68 | +<tr> |
| 69 | +<td>8</td> |
| 70 | +<td><code>000...1000</code></td> |
| 71 | +<td>4</td> |
| 72 | +</tr> |
| 73 | +<tr> |
| 74 | +<td>9</td> |
| 75 | +<td><code>000...1001</code></td> |
| 76 | +<td>3</td> |
| 77 | +</tr> |
| 78 | +<tr> |
| 79 | +<td>10</td> |
| 80 | +<td><code>000...1010</code></td> |
| 81 | +<td>3</td> |
| 82 | +</tr> |
| 83 | +<tr> |
| 84 | +<td>11</td> |
| 85 | +<td><code>000...1011</code></td> |
| 86 | +<td>2</td> |
| 87 | +</tr> |
| 88 | +</tbody> |
| 89 | + </table> |
| 90 | +<p>정수들이 담긴 배열 <code>numbers</code>가 매개변수로 주어집니다. <code>numbers</code>의 모든 수들에 대하여 각 수의 <code>f</code> 값을 배열에 차례대로 담아 return 하도록 solution 함수를 완성해주세요.</p> |
| 91 | + |
| 92 | +<hr> |
| 93 | + |
| 94 | +<h5>제한사항</h5> |
| 95 | + |
| 96 | +<ul> |
| 97 | +<li>1 ≤ <code>numbers</code>의 길이 ≤ 100,000</li> |
| 98 | +<li>0 ≤ <code>numbers</code>의 모든 수 ≤ 10<sup>15</sup></li> |
| 99 | +</ul> |
| 100 | + |
| 101 | +<hr> |
| 102 | + |
| 103 | +<h5>입출력 예</h5> |
| 104 | +<table class="table"> |
| 105 | + <thead><tr> |
| 106 | +<th>numbers</th> |
| 107 | +<th>result</th> |
| 108 | +</tr> |
| 109 | +</thead> |
| 110 | + <tbody><tr> |
| 111 | +<td><code>[2,7]</code></td> |
| 112 | +<td><code>[3,11]</code></td> |
| 113 | +</tr> |
| 114 | +</tbody> |
| 115 | + </table> |
| 116 | +<hr> |
| 117 | + |
| 118 | +<h5>입출력 예 설명</h5> |
| 119 | + |
| 120 | +<p><strong>입출력 예 #1</strong></p> |
| 121 | + |
| 122 | +<ul> |
| 123 | +<li>문제 예시와 같습니다.</li> |
| 124 | +</ul> |
| 125 | + |
| 126 | + |
| 127 | +> 출처: 프로그래머스 코딩 테스트 연습, https://school.programmers.co.kr/learn/challenges |
0 commit comments