-
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);
}
}