Cod sursa(job #1856166)

Utilizator gavrisraulRaul Gavris gavrisraul Data 24 ianuarie 2017 16:44:38
Problema Fractal Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.46 kb
#include <fstream>
using namespace std;
ifstream fin("fractal.in");
ofstream fout("fractal.out");
int k,x,y;

int rez(int k, int x, int y)
{
    if (k==1) return 0;
    k=k/2;
    if (x<=k && y<=k)
        return  rez(k,y,x);
    if (x<=k)
        return  k*k + rez(k,x,y-k);
    if (y<=k)
        return  k*k*3 + rez(k,k-y+1,k-x+k+1);
    return  k*k*2 + rez(k,x-k,y-k);
}


int main()
{
    fin>>k>>x>>y;
    fout<<rez(1<<k,x,y);
    return 0;
}