Pagini recente » Cod sursa (job #151127) | Monitorul de evaluare | Monitorul de evaluare | Cod sursa (job #2017845) | Cod sursa (job #2014575)
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("fractal.in");
ofstream out("fractal.out");
int k, x, y;
long long solverec(int x, int y, int k){
if(k < 0)
return 0;
else if(x <= (1 << k) && y <= (1 << k))
return solverec(y, x, k - 1);
else if(x <= (1 << k) && (1 << k) < y)
return solverec(x, y - (1 << k), k - 1) + (1LL * (1 << (2 * k)));
else if((1 << k) < x && (1 << k) < y)
return solverec(x - (1 << k), y - (1 << k), k - 1) + 2 * (1LL * (1 << (2 * k)));
else
return solverec((1 << k) - y + 1, 2 * (1 << k) - x + 1, k - 1) + 3 * (1LL * (1 << (2 * k)));
}
int main()
{
in >> k >> x >> y;
out << solverec(x, y, k - 1);
in.close();
out.close();
return 0;
}