File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 183
183
- <a href =" https://www.acmicpc.net/problem/2258 " >2258. 정육점</a >
184
184
- <a href =" https://www.acmicpc.net/problem/2513 " >2513. 통학버스</a >
185
185
- <a href =" https://www.acmicpc.net/problem/18768 " >18768. 팀 배정</a >
186
+ - <a href =" https://www.acmicpc.net/problem/1052 " >1052. 물병</a >
186
187
</pre >
187
188
</div >
188
189
</details >
Original file line number Diff line number Diff line change
1
+ package greedy .n1052 ;
2
+
3
+ import java .util .*;
4
+
5
+ public class Main {
6
+ public static void main (String [] args ) {
7
+ Scanner sc = new Scanner (System .in );
8
+ int N = sc .nextInt ();
9
+ int K = sc .nextInt ();
10
+
11
+ int ans = 0 ;
12
+
13
+ // Integer.bitCount(정수): 주어진 정수에서 true의 bit 개수를 찾는 함수
14
+ while (Integer .bitCount (N ) > K ) {
15
+ ans += N & (-N );
16
+ N += N & (-N );
17
+ }
18
+
19
+ System .out .println (ans );
20
+ }
21
+ }
You can’t perform that action at this time.
0 commit comments