Pagini recente » Cod sursa (job #1026157) | Cod sursa (job #2616881) | Cod sursa (job #1340952) | Cod sursa (job #704870) | Cod sursa (job #1469656)
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#include <climits>
#include <list>
#include <iomanip>
#include <cstdlib>
#include <fstream>
#include <map>
#include <algorithm>
#include <string>
#define nmax 1700000
using namespace std;
int f(int p, int x, int y) {
if (p == 0)
return 0;
bool stanga = x <= p;
bool jos = y <= p;
int c;
if (jos)
if (stanga)
return f(p / 2, y, x);
else
return 3 * p * p + f(p / 2, p - y + 1, 2 * p - x + 1);
else if (stanga)
return p * p + f(p / 2, x, y - p);
else
return 2 * p * p + f(p / 2, x - p, y - p);
}
int main() {
freopen("fractal.in", "r", stdin);
freopen("fractal.out", "w", stdout);
ios_base::sync_with_stdio(false);
cin.tie(0);
int k, x, y, p = 1;
cin >> k >> x >> y;
for (int i = 1; i < k; i++)
p *= 2;
int ans = f(p, x, y);
cout << ans;
return 0;
}