Skip to content

Commit 8f72e5a

Browse files
authored
[20250214] BOJ / G3 / 행성 X3 / 권혁준
1 parent b08f7a5 commit 8f72e5a

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
```java
2+
3+
import java.util.*;
4+
import java.io.*;
5+
6+
class Main {
7+
8+
// IO field
9+
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
10+
static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
11+
static StringTokenizer st;
12+
13+
static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());}
14+
static int nextInt() {return Integer.parseInt(st.nextToken());}
15+
static long nextLong() {return Long.parseLong(st.nextToken());}
16+
static void bwEnd() throws Exception {bw.flush();bw.close();}
17+
18+
// Additional field
19+
static long ans = 0;
20+
static long[] cnt;
21+
static long N;
22+
23+
public static void main(String[] args) throws Exception {
24+
25+
ready();
26+
solve();
27+
28+
bwEnd();
29+
30+
}
31+
32+
static void ready() throws Exception{
33+
34+
cnt = new long[20];
35+
N = Integer.parseInt(br.readLine());
36+
for(int i=0;i<N;i++) {
37+
int a = Integer.parseInt(br.readLine());
38+
for(int j=0;j<20;j++) if((a & (1<<j)) != 0) cnt[j]++;
39+
}
40+
41+
}
42+
43+
static void solve() throws Exception{
44+
45+
for(int i=0;i<20;i++) {
46+
ans += (N-cnt[i]) * cnt[i] * (1<<i);
47+
}
48+
bw.write(ans+"\n");
49+
50+
}
51+
52+
}
53+
54+
```

0 commit comments

Comments
 (0)