-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP036_BJ1074_Z.java
More file actions
39 lines (30 loc) · 881 Bytes
/
Copy pathP036_BJ1074_Z.java
File metadata and controls
39 lines (30 loc) · 881 Bytes
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
import java.util.Scanner;
// 분할정복
public class P036_BJ1074_Z {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int r = sc.nextInt();
int c = sc.nextInt();
int answer = 0;
while(N >= 1) { // N이 1보다 클 때
int size = (int) Math.pow(2, N); // N
int area = (int) Math.pow(2, 2 * N); // 넓이
if (r < size / 2 && c < size / 2) { // 1사분면
answer += area / 4 * 0;
} else if (r < size / 2 && c >= size / 2) { // 2사분면
answer += area / 4 * 1;
c -= size / 2;
} else if (r >= size / 2 && c < size / 2) { // 3사분면
answer += area / 4 * 2;
r -= size / 2;
} else if (r >= size / 2 && c >= size / 2) { // 4사분면
answer += area / 4 * 3;
r -= size / 2;
c -= size / 2;
}
N--;
}
System.out.println(answer);
}
}