We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f0bfbf6 commit 8c4ec3dCopy full SHA for 8c4ec3d
1 file changed
suyeun84/202508/10 BOJ G5 두 배 더하기.md
@@ -0,0 +1,33 @@
1
+```java
2
+import java.io.*;
3
+import java.util.*;
4
+
5
+public class boj12931 {
6
+ static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
7
+ static StringTokenizer st;
8
+ static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());}
9
+ static int nextInt() {return Integer.parseInt(st.nextToken());}
10
11
+ public static void main(String[] args) throws Exception {
12
+ nextLine();
13
+ int N = nextInt();
14
15
+ int add = 0, multi = 0;
16
+ for (int i = 0; i < N; i++) {
17
+ int b = nextInt();
18
+ int cnt = 0;
19
+ while (b > 0) {
20
+ if (b % 2 == 1) {
21
+ b--;
22
+ add++;
23
+ } else {
24
+ b /= 2;
25
+ cnt++;
26
+ }
27
28
+ multi = Math.max(multi, cnt);
29
30
+ System.out.println(add + multi);
31
32
+}
33
+```
0 commit comments