Pagini recente » Cod sursa (job #3180545) | Cod sursa (job #2756599) | Cod sursa (job #638836) | Cod sursa (job #195724) | Cod sursa (job #2344743)
#include <fstream>
using namespace std;
ifstream fin("fractal.in");
ofstream fout("fractal.out");
int n,k,x,y,i,l;
int solve(){
int nr=0;
while(x>1 || y>1){
l/=2;
if(x<=l && y<=l){ //CADRAN I
swap(x,y);
}
else if(x>l && y<=l){ //CADRAN II
nr+=l*l;
x-=l;
}
else if(x>l && y>l){ //CADRAN III
nr+=2*l*l;
x-=l;
y-=l;
}
else{ //CADRAN IV
nr+=3*l*l;
y-=l;
y=l-y+1;
x=l-x+1;
swap(x,y);
}
}
return nr;
}
int main()
{
fin>>k>>y>>x;
l=(1<<k);
int sol=solve();
fout<<sol;
return 0;
}