-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBOJ1074.java
More file actions
42 lines (37 loc) · 1.01 KB
/
BOJ1074.java
File metadata and controls
42 lines (37 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package ¹éÁØ;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class BOJ1074 {
static int N, R, C, cnt;
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
N = Integer.parseInt(st.nextToken());
R = Integer.parseInt(st.nextToken());
C = Integer.parseInt(st.nextToken());
int n = (int) Math.pow(2, N);
s(R, C, n);
}
public static void s(int r, int c, int size) {
if(size == 1) {
System.out.print(cnt);
return;
}
int n = size / 2;
if (r < n && c < n) {
cnt += n * n * 0;
s(r, c, n);
} else if (r < n && c < n + n) {
cnt += n * n * 1;
s(r, c - n, n);
} else if (r < n + n && c < n) {
cnt += n * n * 2;
s(r - n, c, n);
} else if (r < n + n && c < n + n) {
cnt += n * n * 3;
s(r - n, c - n, n);
}
}
}