-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBOJ_1074.cpp
More file actions
49 lines (44 loc) · 796 Bytes
/
BOJ_1074.cpp
File metadata and controls
49 lines (44 loc) · 796 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
40
41
42
43
44
45
46
47
48
49
//21 10 14
#include <iostream>
using namespace std;
int n, r, c;
int result = 0;
void Divide(int ra, int rb, int ca, int cb)
{
if ((rb-ra)==1)
return;
int dx = (rb-ra)/2;
if (r<ra+dx)
{
if (c<ca+dx)
Divide(ra, ra+dx, ca, ca+dx);
else
{
result += dx*dx;
Divide(ra, ra+dx, ca+dx, cb);
}
}
else
{
if (c<ca+dx)
{
result += 2*dx*dx;
Divide(ra+dx, rb, ca, ca+dx);
}
else
{
result += 3*dx*dx;
Divide(ra+dx, rb, ca+dx, cb);
}
}
}
int main(void)
{
cin >> n >> r >> c;
int num = 1;
for (int i=0; i<n; i++)
num*=2;
Divide(0, num, 0, num);
cout << result;
return 0;
}