Pagini recente » Cod sursa (job #536214) | Cod sursa (job #2845370) | Cod sursa (job #652959) | Cod sursa (job #2929139) | Cod sursa (job #1711107)
#include <stdio.h>
#include <stdlib.h>
int wtf(int k, int x, int y){
if(k==1) return 0;
k/=2;
if(x<=k && y<=k) return wtf(k, y, x);
if(x<=k) return k*k+wtf(k, x, y-k);
if(y<=k) return 3*k*k+wtf(k, k-y+1, 2*k-x+1);
return 2*k*k+wtf(k, x-k, y-k);
}
int main(){
int k, x, y;
FILE*fi,*fo;
fi=fopen("fractal.in","r");
fo=fopen("fractal.out","w");
fscanf(fi,"%d%d%d", &k, &x, &y);
fprintf(fo,"%d", wtf(1<<k, x, y));
fclose(fi);
fclose(fo);
return 0;
}