Cod sursa(job #1404108)

Utilizator andrei20003Ionescu Andrei andrei20003 Data 27 martie 2015 19:43:04
Problema Fractal Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.49 kb
#include <fstream>
using namespace std;
ifstream fin("fractal.in");
ofstream fout("fractal.out");
int n,x,y;
int divimp(int n, int x, int y)
{
if(n==0)
    return 0;
n--;
int len= 1 << n;
if(x<=len&&y<=len)
        return divimp(n,y,x);
if(x>len&&y<=len)
        return len*len+divimp(n,x-len,y);
if(x>len&&y>len)
        return 2*len*len+divimp(n,x-len,y-len);
return 3*len*len+divimp(n,2*len-y+1,len-x+1);

}
int main()
{
fin>>n>>y>>x;
fout<<divimp(n,x,y);
    return 0;