File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 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+ nextLine();
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+ ```
You can’t perform that action at this time.
0 commit comments