Pagini recente » Cod sursa (job #2766221) | Cod sursa (job #3201605) | Cod sursa (job #823310) | Cod sursa (job #1931157) | Cod sursa (job #30917)
Cod sursa(job #30917)
#include<stdio.h>
#include<math.h>
unsigned int i,j,k;
long curba(int i,int j,int k)
{if(k==0) return 1;
long n=pow(2,k-1),m=n*n;
long nr=0;
unsigned int a;
if(i<=n)if(j<=n){a=i;i=j;j=i;j=n-j+1;}
else{nr=3*n*n; a=i;i=j;j=i;j=n-j+1;i=n-i+1;}
else if(j<=n) nr=n*n;
else nr=n*n*2;
nr=nr+curba(i,j,k-1);
return nr;
}
int main()
{freopen("fractal.in","r",stdin);
freopen("fractal.out","w",stdout);
scanf("%d %d %d",&i,&j,&k);
printf("%ld",curba(i,j,k));
fclose(stdout);
return 0;}