Pagini recente » Cod sursa (job #2256538) | Cod sursa (job #1410252) | Cod sursa (job #466448) | Cod sursa (job #1652246) | Cod sursa (job #1004492)
#include <fstream>
using namespace std;
ifstream f("fractal.in");
ofstream g("fractal.out");
int k, x, y;
int p[16]={1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768};
int dep(int k, int x, int y){
if(k<0)
return 0;
if(x<=p[k])
{
if(y<=p[k])
return dep(k-1, y, x);
else
return dep(k-1, 2*p[k]-y+1, p[k]-x+1)+3*p[k]*p[k];
}
else
{
if(y<=p[k])
return dep(k-1, x-p[k], y)+p[k]*p[k];
else
return dep(k-1, x-p[k], y-p[k])+2*p[k]*p[k];
}
}
int main(){
f>>k>>x>>y;
g<<dep(k, x, y)<<"\n";
return 0;
}