Pagini recente » Cod sursa (job #1789046) | Cod sursa (job #908011) | Cod sursa (job #2226276) | Cod sursa (job #50722) | Cod sursa (job #591971)
Cod sursa(job #591971)
var f:text;
k,x,y,nr,aux,i,sol:longint;
begin
assign(f,'fractal.in');reset(f);
readln(f,k,x,y);
close(f);
assign(f,'fractal.out');rewrite(f);
nr:=1;
for i:=1 to k do
nr:=nr*2;
repeat
nr:=nr div 2;
if x>nr then
if y<=nr then
begin
dec(x,nr);
sol:=sol+3*nr*nr;
end
else
begin
dec(x,nr);
dec(y,nr);
sol:=sol+2*nr*nr;
end
else
if y>nr then
begin
dec(y,nr);
sol:=sol+nr*nr;
end
else
begin
aux:=x;
x:=y;
y:=aux;
end;
until nr<=2;
if (x=2) and (y=1) then
inc(sol,3);
if (x=2) and (y=2) then
inc(sol,2);
if (x=1) and (y=2) then
inc(sol,1);
writeln(f,sol);
close(f);
end.