Pagini recente » Borderou de evaluare (job #396987) | Borderou de evaluare (job #1567907) | Borderou de evaluare (job #1259547) | Borderou de evaluare (job #1999868) | Cod sursa (job #491901)
Cod sursa(job #491901)
#include <fstream>
using namespace std;
const char InFile[]="fractal.in";
const char OutFile[]="fractal.out";
const int MaxK=20;
ifstream fin(InFile);
ofstream fout(OutFile);
int k,x,y,a[MaxK],l,cf,rotation;
int cost(int k,int x,int y)
{
if(k==0)
{
return 0;
}
int v=1<<(k-1);
if(x<=v)
{
if(y<=v)
{
return cost(k-1,y,x);
}
else
{
return v*v+cost(k-1,x,y-v);
}
}
if(y<=v)
{
return 3*v*v+cost(k-1,v-y+1,v-x+1);
}
else
{
return 2*v*v+cost(k-1,x-v,y-v);
}
}
int main()
{
fin>>k>>x>>y;
fin.close();
int sol=cost(k,x,y);
fout<<sol;
fout.close();
return 0;
}