We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 38cff75 commit 693a5b0Copy full SHA for 693a5b0
suyeun84/202511/05 BOJ G5 물병.md
@@ -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