Pagini recente » Cod sursa (job #1412625) | Cod sursa (job #1578657) | Cod sursa (job #2721397) | Cod sursa (job #231308) | Cod sursa (job #1242586)
#include <fstream>
using namespace std;
ifstream in("fractal.in");
ofstream out("fractal.out");
int sol=0;
void rez(int k, int x, int y)
{
if(k==0)
return;
int put;
put=(1<<(k-1));
if(x<=put&&y<=put)
{
rez(k-1,y,x);
}
else
if(x>put&&y<=put)
{
sol+=put*put;
rez(k-1,x-put,y);
}
else
if(x>put&&y>put)
{
sol+=2*put*put;
rez(k-1,x-put,y-put);
}
else
if(x<=put&&y>put)
{
sol+=3*put*put;
rez(k-1,put-(y-put)+1,put-x+1);
}
}
int main()
{
int x,y,k;
in>>k>>x>>y;
rez(k,y,x);
out<<sol<<'\n';
return 0;
}