Cod sursa(job #1711107)

Utilizator andreicoman299Coman Andrei andreicoman299 Data 30 mai 2016 16:13:28
Problema Fractal Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.52 kb
#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;
}