Pagini recente » Cod sursa (job #114787) | Cod sursa (job #366845) | Cod sursa (job #2243445) | Cod sursa (job #277546) | Cod sursa (job #1800564)
#include <fstream>
//#include <algorithm>
//#include <vector>
using namespace std;
ifstream fin("fractal.in");
ofstream fout("fractal.out");
int N, X, Y;
//vector<int> V;
void DEI(int K, int x, int y, long long pasi) {
if (x == X && y == Y) {
//V.push_back(pasi);
//fout << X << ", " << Y << " => " << pasi << "\n";
fout << pasi;
return;
}
int pieces = (1 << (2 * K - 2));
int lg = 1 << (K - 1);
if (X < x + lg && Y < y + lg)
DEI(K - 1, x, y, pasi + 0LL * pieces);
else if (X >= x + lg && Y < y + lg)
DEI(K - 1, x + lg, y, pasi + 1LL * pieces);
else if (X >= x + lg && Y >= y + lg)
DEI(K - 1, x + lg, y + lg, pasi + 2LL * pieces);
else if (X < x + lg && Y >= y + lg)
DEI(K - 1, x, y + lg, pasi + 3LL * pieces);
}
int main(){
fin >> N >> Y >> X;
/*for (int i = 1; i <= (1 << N); ++i)
for (int j = 1; j <= (1 << N); ++j ) {
X = i;
Y = j;*/
DEI(N, 1, 1, 0);
/*
sort(V.begin(), V.end());
vector<int> :: iterator it;
for (it = V.begin(); it != V.end(); ++it)
fout << *it << " ";
*/
return 0;
}