Mai intai trebuie sa te autentifici.
Cod sursa(job #526194)
| Utilizator | Data | 27 ianuarie 2011 18:51:46 | |
|---|---|---|---|
| Problema | Fractal | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.58 kb |
#include <stdio.h>
FILE *f,*s;
long int z;
void Rezolva(long int k,long int x,long int y)
{
if(k==0) return;
int l=(1<<(k-1));
if(x<=l && y<=l) Rezolva(k-1,y,x);
if(x>l && y<=l) { z+=l*l; Rezolva(k-1,x-l,y); }
if(x>l && y>l) { z+=2*l*l; Rezolva(k-1,x-l,y-l); }
if(x<=l && y>l) { z+=3*l*l; Rezolva(k-1,2*l-y+1,l-x+1); }
}
int main()
{
long int k,x,y;
f=fopen("fractal.in","r");
s=fopen("fractal.out","w");
fscanf(f,"%ld %ld %ld",&k,&x,&y);
Rezolva(k,y,x);
fprintf(s,"%ld",z);
fclose(s);
return 0;
}