Pagini recente » Cod sursa (job #71382) | Cod sursa (job #2425864) | Cod sursa (job #2970168) | Cod sursa (job #1401097) | Cod sursa (job #1856166)
#include <fstream>
using namespace std;
ifstream fin("fractal.in");
ofstream fout("fractal.out");
int k,x,y;
int rez(int k, int x, int y)
{
if (k==1) return 0;
k=k/2;
if (x<=k && y<=k)
return rez(k,y,x);
if (x<=k)
return k*k + rez(k,x,y-k);
if (y<=k)
return k*k*3 + rez(k,k-y+1,k-x+k+1);
return k*k*2 + rez(k,x-k,y-k);
}
int main()
{
fin>>k>>x>>y;
fout<<rez(1<<k,x,y);
return 0;
}