Pagini recente » Cod sursa (job #1356182) | Cod sursa (job #1527323) | Cod sursa (job #2834061) | Cod sursa (job #2741902) | Cod sursa (job #2344058)
#include <fstream>
using namespace std;
ifstream fin("fractal.in");
ofstream fout("fractal.out");
int n,k,x,y,nr,L;
int main()
{
fin>>k>>y>>x;
L=1<<k;
while(x>1||y>1)
{
L=L/2;
if(x<=L&&y<=L)
swap(x,y);
else if(x>L&&y<=L)
{
nr+=L*L;
x=x-L;
}
else if(x>L&&y>L)
{
nr+=2*L*L;
y-=L;
x-=L;
}
else
{
nr+=3*L*L;
y=y-L;
if(y<=L/2&&x<=L/2||x>L/2&&y>L/2)
{
x=L-x+1;
y=L-y+1;
swap(x,y);
}
}
}
fout<<nr;
return 0;
}