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