Pagini recente » Cod sursa (job #2610475) | Cod sursa (job #2258187) | Cod sursa (job #330718) | Cod sursa (job #1565180) | Cod sursa (job #2268977)
#include <fstream>
#include <vector>
std::ifstream cin("fractal.in");
std::ofstream cout("fractal.out");
int fractal(int k,int x,int y,int totalupto)
{
if(k>0){
if(x>(1<<(k-1))&&y<=(1<<(k-1)))
return totalupto*2 + totalupto + fractal(k-1 ,(1<<(k-1))-y+1 , (1<<(k-1))-(x-(1<<(k-1)))+1,totalupto/4);
else
if(x>(1<<(k-1)))
return totalupto*2 + fractal(k-1 , x-(1<<(k-1)) , y-(1<<(k-1)), totalupto/4);
else
if(y>(1<<(k-1)))
return totalupto + fractal(k-1, x , y-(1<<(k-1)) , totalupto/4);
else
return fractal(k-1 , y , x , totalupto/4);
}
else
return 0;
}
int main()
{
int k,x,y,total=1;
cin>>k>>x>>y;
for(int i=1;i<k;total*=4,i++);
cout<<fractal(k,x,y,total);
}