Pagini recente » Cod sursa (job #1469252) | Cod sursa (job #394724) | Cod sursa (job #2955551) | Cod sursa (job #1165311) | Cod sursa (job #2449352)
#include <fstream>
using namespace std;
ifstream in("fractal.in");
ofstream out("fractal.out");
inline int compute(int k, int x, int y)
{
if (k == 1)
return 0;
k >>= 1;
if (x <= k && y <= k)
return compute(k, y, x);
if (x <= k)
return k * k + compute(k, x, y - k);
if (y <= k)
return 3 * k * k + compute(k, k - y + 1, 2 * k - x + 1);
return 2 * k * k + compute(k, x - k, y - k);
}
int main()
{
int k, x, y;
in >> k >> x >> y;
out << compute((1 << k), x, y);
return 0;
}