Pagini recente » Cod sursa (job #188310) | Cod sursa (job #1158915) | Cod sursa (job #2616225) | Cod sursa (job #3266252) | Cod sursa (job #2523605)
#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
const string file = "fractal";
const ll INF = 9223372036854775807ll;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, inf = 2147483647;
int rec(int n, int x, int y)
{
if (n == 0)
return 0;
int step = 1<<(n-1);
if (x < step && y < step)
return rec(n-1, y, x);
if (x < step)
return rec(n-1, step-1-(y-step), step-1-x)+3*(step*step);
if (y < step)
return rec(n-1, x-step, y)+(step*step);
return rec(n-1, x-step, y-step)+2*(step*step);
}
int main()
{
ifstream fin (file+".in");
ofstream fout (file+".out");
int n, x, y;
fin >> n >> x >> y;
swap(x, y);
--x, --y;
fout << rec(n, x, y) << "\n";
return 0;
}