Pagini recente » Cod sursa (job #2362199) | Cod sursa (job #2821060) | Cod sursa (job #1020066) | Cod sursa (job #2826778) | Cod sursa (job #1233581)
#include<fstream>
#include<iostream>
#include<cmath>
using namespace std;
ifstream f("fractal.in");
ofstream g("fractal.out");
int S;
void divide(int,int,int);
int main()
{
int K,x,y;
f>>K>>y>>x;
divide(K,x,y);
g<<S;
f.close();g.close();
}
void divide(int K,int x,int y)
{
if (K<1)
{
return;
}
else
{
int mij=pow(2,K-1),arie=mij*mij;
if (x<=mij && y<=mij)
divide(K-1,y,x);
else if (x<=mij)
{
S+=3*arie;
divide(K-1,2*mij-y+1,mij-x+1);
}
else if (x>mij && y>mij)
{
S+=2*arie;
divide(K-1,x-mij,y-mij);
}
else
{
S+=arie;
divide(K-1,x-mij,y);
}
}
}