Pagini recente » Cod sursa (job #1772165) | Cod sursa (job #1930742) | Cod sursa (job #723583) | Cod sursa (job #2803257) | Cod sursa (job #2968537)
#include <fstream>
using namespace std;
ifstream f("fractal.in");
ofstream g("fractal.out");
int k,x,y;
int sol(int k,int x,int y)
{
if(k==0)
return 0;
k--;
int p=(1<<k);
if(x<=p&&y<=p)
{
return sol(k,y,x);
}
else
if(x>p&&y>p)
{
return p*p*2+sol(k,x-p,y-p);
}
else
if(x>p&&y<=p)
{
return p*p+sol(k,x-p,y);
}
else
{
return 3*p*p+sol(k,p*2+1-y,p+1-x);
}
}
int main()
{
f>>k>>y>>x;
g<<sol(k,x,y);
return 0;
}