Pagini recente » Cod sursa (job #1895203) | Cod sursa (job #464135) | Cod sursa (job #220780) | Cod sursa (job #3161032) | Cod sursa (job #1017173)
#include <cstdio>
#include <cstdlib>
int megoldas(int k, int x, int y)
{
if (k==0) return 0;
if (x <= 1<<(k-1) && y <= 1<<(k-1))
return megoldas(k-1, y, x);
if (x > 1<<(k-1) && y > 1<<(k-1))
return 2*(1<<(k-1))*(1<<(k-1)) + megoldas(k-1, x - 1<<(k-1), y - 1<<(k-1));
if (x > 1<<(k-1) && y <= 1<<(k-1))
return (1<<(k-1))*(1<<(k-1)) + megoldas(k-1, x - 1<<(k-1), y);
return 3*(1<<(k-1))*(1<<(k-1)) + megoldas(k-1, 2 *(1<<(k-1)) - y + 1, 1<<(k-1) - x + 1);
}
int main()
{
freopen("fractal.in", "r", stdin);
freopen("fractal.out", "w", stdout);
int k, x, y;
scanf("%d%d%d", &k, &x, &y);
printf("%d", megoldas(k, y, x));
return 0;
}