Skip to content

Commit f3cf9e6

Browse files
authored
[20251105] BOJ / G5 / 물병 / 김수연
[20251105] BOJ / G5 / 물병 / 김수연
2 parents e931752 + 693a5b0 commit f3cf9e6

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
```java
2+
import java.io.*;
3+
import java.util.*;
4+
5+
public class Main {
6+
public static void main(String[] args) throws IOException {
7+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
8+
StringTokenizer st = new StringTokenizer(br.readLine(), " ");
9+
10+
int n = Integer.parseInt(st.nextToken());
11+
int k = Integer.parseInt(st.nextToken());
12+
13+
int ans = solution(n, k);
14+
System.out.println(ans);
15+
}
16+
17+
public static int solution(int n, int k) {
18+
int ans = 0;
19+
while(Integer.bitCount(n) > k) {
20+
n ++;
21+
ans ++;
22+
}
23+
return ans;
24+
}
25+
}
26+
```

0 commit comments

Comments
 (0)