Pagini recente » Monitorul de evaluare | Cod sursa (job #2323940) | Istoria paginii runda/pregatire_oji | Cod sursa (job #882692) | Cod sursa (job #2343840)
#include <fstream>
using namespace std;
ifstream fin("fractal.in");
ofstream fout("fractal.out");
int n,x,y,l,i;
int main()
{
fin>>l>>y>>x;
int nr=0;
l=1<<l;
while(x>1||y>1)
{
l=l/2;
if(x<=l&&y<=l)
swap(x,y);
else
if(x>l&&y<=l)
{
nr=nr+l*l;
x=x-l;
}
else
if(x>l&&y>l){
nr=nr+2*l*l;
x-=l;y-=l;
}
else
{
nr=nr+3*l*l;
y=y-l;
if(x>l/2&&y>l/2){
x=l/2-x+1;
y=l/2-y+1;
}
else
if( x<=l/2&&y<=l/2){
x=(l/2+x);
y=(l/2+y);
x=x-l/2+1;
y=y-l/2+1;
}
}
}
fout<<nr;
return 0;
}