Pagini recente » Cod sursa (job #1116859) | Cod sursa (job #2151708) | Cod sursa (job #317800) | Cod sursa (job #367837) | Cod sursa (job #2192534)
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<ld, ld>
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
int Solve(int k, int x, int y) {
if (k == 1) {
return 0;
}
k /= 2;
if (x <= k && y <= k) {
return Solve(k, y, x);
} else if (x <= k) {
return k * k + Solve(k, x, y - k);
} else if (y <= k) {
return 3 * k * k + Solve(k, k - y + 1, 2 * k - x + 1);
} else {
return 2 * k * k + Solve(k, x - k, y - k);
}
}
int main() {
cin.sync_with_stdio(false);
ifstream cin("fractal.in");
ofstream cout("fractal.out");
int k, x, y;
cin >> k >> x >> y;
cout << Solve(1 << k, x, y) << '\n';
return 0;
}