Pagini recente » Cod sursa (job #1743161) | Cod sursa (job #346616) | Profil mihnea.anghel | Cod sursa (job #3003322) | Cod sursa (job #1483070)
#include <cstdio>
using namespace std;
int x, y, t, k, d;
int rec( int x1, int y1, int x2, int y2 ){
if( x1 == x2 && x2 == x && y1 == y2 && y2 == y ) return 0;
else{
k--;
d = 1 << k;
d *= d;
//printf("%d\n",t);
int mid_x = ( x1 + x2 ) / 2;
int mid_y = ( y1 + y2 ) / 2;
if( x <= mid_x ){
if( y <= mid_y ){
rec( x1, y1, mid_x, mid_y );
}
else{
t += d * 3;
rec( x1, mid_y+1, mid_x, y2 );
}
}
else{
if( y <= mid_y ){
t += d;
rec( mid_x+1, y1, x2, mid_y );
}
else{
t += d * 2;
rec( mid_x+1, mid_y+1, x2, y2 );
}
}
}
}
int main()
{
freopen("fractal.in","r",stdin);
freopen("fractal.out","w",stdout);
int d, s;
scanf("%d%d%d",&k,&x,&y);
rec( 1, 1, 1 << k, 1 << k );
printf("%d",t);
return 0;
}