Cod sursa(job #1379001)

Utilizator GinguIonutGinguIonut GinguIonut Data 6 martie 2015 15:35:31
Problema Fractal Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.5 kb
#include <fstream>
using namespace std;
ifstream fin("fractal.in");
ofstream fout("fractal.out");
int n,x,y,mat[3][3],x1,y1;
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>>x>>y;
fout<<divimp(n,x,y);
    return 0;
}