-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1074.cpp
More file actions
43 lines (40 loc) · 874 Bytes
/
1074.cpp
File metadata and controls
43 lines (40 loc) · 874 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
#include <bits/stdc++.h>
#include <math.h>
#define SETTING ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
using namespace std ;
int N, R, C, answer ;
void DivideAndConquer(int N, int R, int C)
{
if(N == 1) return ;
if(R < N / 2)
{
if(C < N / 2)
DivideAndConquer(N / 2, R, C) ;
else
{
answer += pow(N/2, 2) ;
DivideAndConquer(N / 2, R, C - (N / 2)) ;
}
}
else
{
if(C < N / 2)
{
answer += (pow(N/2, 2) * 2) ;
DivideAndConquer(N / 2, R - (N / 2), C) ;
}
else
{
answer += (pow(N/2, 2) * 3) ;
DivideAndConquer(N / 2, R - (N / 2), C - (N / 2)) ;
}
}
}
int main()
{
SETTING ;
cin >> N >> R >> C ;
DivideAndConquer((1 << N), R, C) ;
cout << answer ;
}