-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1074.cpp
More file actions
80 lines (77 loc) · 1.41 KB
/
1074.cpp
File metadata and controls
80 lines (77 loc) · 1.41 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
long long cnt;
long long ac;
long long a;
long long b;
long long divide(long long y, long long x, long long ans, long long mul)
{
if(ans<16)
{
if(a==y&&b==x)
{
ac = cnt;
return 0;
}
cnt++;
if(a==y&&b==x+1)
{
ac = cnt;
return 0;
}
cnt++;
if(a==y+1&&b==x)
{
ac = cnt;
return 0;
}
cnt++;
if(a==y+1&&b==x+1)
{
ac = cnt;
return 0;
}
cnt++;
return 0;
}
if(x+mul>b&&y+mul>a)
{
divide(y,x,ans/4,mul/2);
}
else if(x+mul<=b&&y+mul>a)
{
cnt = cnt + ans/4;
divide(y,x+mul,ans/4,mul/2);
}
else if(x+mul>b&&y+mul<=a)
{
cnt = cnt + (ans/4)*2;
divide(y+mul,x,ans/4,mul/2);
}
else if(x+mul<=b&&y+mul<=a)
{
cnt = cnt + (ans/4)*3;
divide(y+mul,x+mul,ans/4,mul/2);
}
return 0;
}
int main(int argc, char** argv)
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long ans = 1;
int num;
cin>>num>>a>>b;
for(int i = 1; i <=num; i++ )
{
ans = ans *2;
}
long long mul = ans/2;
ans = ans *ans;
divide(0,0,ans,mul);
cout<<ac<<"\n";
return 0;
}