Pagini recente » Cod sursa (job #287497) | Cod sursa (job #420471) | Cod sursa (job #1309135) | Cod sursa (job #1913654) | Cod sursa (job #591602)
Cod sursa(job #591602)
#include <fstream>
using namespace std;
ifstream in("fractal.in");
ofstream out("fractal.out");
int n,x,y,aux=1,m;
int main(){
in>>n>>x>>y;
for(int i=1;i<n;i++){
aux=aux*2;
}
while(n>=2){
if(x<aux){
if(y>=aux){
m+=aux*2;
}
else{
aux=aux/2;
n--;
x=x+y;
y=x-y;
x=x-y;
continue;
}
}
else{
if(y<=aux)
m+=3*aux*2;
else
m+=4*aux;
}
y=y/2;
x=x/2;
if(y==0)
y=1;
if(x==0)
x=1;
x=x+y;
y=x-y;
x=x-y;
aux=aux/2;
n--;
}
if(x==1){
if(y==2){
m+=3;
}
else{
m++;
}
}
else{
if(y==1){
m++;
}
else{
m+=2;
}
}
out<<m;
return 0;
}