Cod sursa(job #2449352)
Utilizator | Data | 19 august 2019 13:39:01 | |
---|---|---|---|
Problema | Fractal | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.56 kb |
#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;
}