Pagini recente » Cod sursa (job #2535278) | Cod sursa (job #1363044) | Cod sursa (job #344824) | Cod sursa (job #1617490) | Cod sursa (job #2625239)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin ("fractal.in");
ofstream fout ("fractal.out");
int ordin;
long long x, y;
long long pasi;
long long put;
long long fract (long long coordx, long long coordy)
{
if(ordin==1)
{
if(coordx==2 && coordy==1) pasi++;
else if(coordx==2 && coordy==2) pasi+=2;
else if(coordx==1 && coordy==2) pasi+=3;
return pasi;
}
ordin--;
put/=2;
if(coordx<=put && coordy<=put) //cadranul 1
{
fract(coordy, coordx);
}
else if(coordx>put && coordy<=put) // cadranul 2
{
pasi+=put*put;
fract(coordx-put, coordy);
}
else if(coordx<=put && coordy>put) // cadranul 4
{
pasi+=3*put*put;
fract(2*put-coordy+1, put+1-coordx);
}
else if(coordx>put && coordy>put) //cadranul 3
{
pasi+=2*put*put;
fract(coordx-put, coordy-put);
}
}
int main()
{
fin>>ordin>>y>>x;
put=1<<ordin;
fout<<fract(x, y);
return 0;
}