-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboj1074.cpp
More file actions
59 lines (53 loc) · 1.24 KB
/
boj1074.cpp
File metadata and controls
59 lines (53 loc) · 1.24 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using p = pair<int, int>;
const int INF = 0x66554433;
inline void quick_IO(){
ios_base :: sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
}
int counts;
int answer;
int n = 1;
int N, r, c;
void calc(int x1, int y1, int x2, int y2){
if(r>=x1&&r<x2&&c>=y1&&c<y2){
// 범위 안에 있을 때만 4분할해서 계산한다.
if(r==x1&&c==y1){
answer = counts;
return;
}
int d = (x2-x1)/2;
for(int i = 0;i<2;i++){
for (int j = 0; j < 2; ++j) {
int new_x1 = x1+i*d;
int new_y1 = y1+j*d;
int new_x2 = x1+(i+1)*d;
int new_y2 = y1+(j+1)*d;
calc(new_x1, new_y1, new_x2, new_y2);
}
}
}else{
// r, c가 범위 안에 없으면 해당 범위만큼 수를 더하고 바로 리턴
counts += (x2-x1)*(y2-y1);
return;
}
}
int main(){
quick_IO();
cin>>N>>r>>c;
while(N--){
n*=2;
}
calc(0, 0, n, n);
cout<<answer<<endl;
return 0;
}