Skip to content

Commit 80cc8b1

Browse files
authored
Merge pull request #753 from AlgorithmWithGod/Ukj0ng
[20250827] BOJ / G3 / 비트코인은 신이고 나는 무적이다 / 한종욱
2 parents 27712da + e993157 commit 80cc8b1

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
```
2+
import java.io.*;
3+
import java.util.*;
4+
5+
public class Main {
6+
private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
7+
private static final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
8+
private static TreeSet<Integer>[] dp;
9+
private static int[] arr;
10+
private static int N, M;
11+
12+
public static void main(String[] args) throws IOException {
13+
init();
14+
DP();
15+
16+
bw.write(dp[M].last() + "\n");
17+
18+
bw.flush();
19+
bw.close();
20+
br.close();
21+
}
22+
23+
private static void init() throws IOException {
24+
StringTokenizer st = new StringTokenizer(br.readLine());
25+
N = Integer.parseInt(st.nextToken());
26+
M = Integer.parseInt(st.nextToken());
27+
28+
arr = new int[N + 1];
29+
dp = new TreeSet[M + 1];
30+
31+
for (int i = 0; i <= M; i++) {
32+
dp[i] = new TreeSet<>();
33+
}
34+
35+
st = new StringTokenizer(br.readLine());
36+
for (int i = 1; i <= N; i++) {
37+
arr[i] = Math.abs(Integer.parseInt(st.nextToken()));
38+
}
39+
}
40+
41+
private static void DP() {
42+
dp[0].add(0);
43+
for (int i = 1; i <= M; i++) {
44+
for (int j = 1; j <= N; j++) {
45+
for (int val : dp[i - 1]) {
46+
dp[i].add(arr[j] ^ val);
47+
}
48+
}
49+
}
50+
}
51+
}
52+
53+
```

0 commit comments

Comments
 (0)