Cod sursa(job #30917)

Utilizator razvi9Jurca Razvan razvi9 Data 15 martie 2007 12:05:50
Problema Fractal Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.51 kb
#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;}