Pagini recente » Cod sursa (job #3250656) | Cod sursa (job #28175) | Diferente pentru propuneri/6-arhiva-educationala intre reviziile 5 si 16 | Cod sursa (job #120775) | Cod sursa (job #132652)
Cod sursa(job #132652)
#include<stdio.h>
#include<math.h>
int i,j,k;
int poz(int i,int j,int k)
{
if(k==1)
if(i==1)
if(j==1) return 0;
else
return 3;
else
if(j==1) return 1;
else return 2;
int size=1<<(k-1);
int cost,i1,j1;
if(i>size)
if(j>size){
cost=size*size*2;
i1=i-size;
j1=j-size;
cost+=poz(i1,j1,k-1);}
else{
cost=size*size;
i1=i-size;
j1=j;
cost+=poz(i1,j1,k-1);}
else
if(j>size){
cost=3*size*size;
j1=j-size;
i1=size-j1+1;
j1=i;
cost+=size*size-poz(i1,j1,k-1)-1;}
else{
cost=0;
i1=j;
j1=size-i+1;
cost+=size*size-poz(i1,j1,k-1)-1;}
return cost;
}
int main()
{freopen("fractal.in","r",stdin);
freopen("fractal.out","w",stdout);
scanf("%d %d %d",&k,&j,&i);
printf("%d",poz(i,j,k));
fclose(stdout);
return 0;}