-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1074.cpp
40 lines (36 loc) · 785 Bytes
/
1074.cpp
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
#include <iostream>
using namespace std;
int main(void){
int n, r, c;
cin >> n >> r >> c;
int curCount=0;
while(n){
bool row = false;
bool col = false;
int half = 1 << (n-1);
if(r >= half)
row = true;
if(c >= half)
col = true;
int quarter = 1 << (2*n-2);
if(row && col){//1 1
curCount += quarter*3;
r -= half;
c -= half;
}
else if(row){//1 0
curCount += quarter*2;
r -= half;
}
else if(col){//0 1
curCount += quarter*1;
c -= half;
}
else{//0 0
curCount += quarter*0;
}
n--;
}
cout << curCount;
return 0;
}