Cod sursa(job #2269262)

Utilizator denmirceaBrasoveanu Mircea denmircea Data 25 octombrie 2018 20:11:33
Problema Fractal Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.71 kb
#include <fstream>
using namespace std;
int k,n,x,y;
int solutie;
ifstream fin("fractal.in");
ofstream fout("fractal.out");
void fractal(int k, int x, int y) {
    if (k>0){
            k--;
            int n=(1<<k);
        if (x <= n && y <= n)
            fractal(k , y, x);
    else
        if (x > n && y <= n){
            solutie += n*n;
            fractal(k , x - n, y);
        }
    else
        if (x <= n && y > n) {
            solutie += 3*n*n;
            fractal(k , 2*n + 1 - y, n - x + 1);
        }
    else{
            solutie += 2*n*n;
            fractal(k , x - n, y - n);
        }
    }
}

int main()
{
    fin>>k>>y>>x;
    fractal(k,x,y);
    fout<<solutie;

}