Pagini recente » Cod sursa (job #2802660) | Cod sursa (job #169378) | Cod sursa (job #1632988) | Cod sursa (job #2946364) | Cod sursa (job #3143427)
#define _GLIBCXX_FILESYSTEM
#include <bits/stdc++.h>
using namespace std;
ifstream fin("fractal.in");
ofstream fout("fractal.out");
int k, i, j, x, y, sol, n;
int main(){
fin >> k >> j >> i;
int t;
while(k > 0){
k--;
t = (1 << k);
n = t * t;
if(i <= t && j <= t){
x = j;
y = t - i + 1;
y = t - y + 1;
i = x;
j = y;
}else{
if(i <= t && j > t){
j -= t;
x = t - j + 1;
y = i;
y = t - y + 1;
i = x;
j = y;
sol += n * 3;
}else{
if(i > t && j <= t){
i -= t;
sol += n;
}else{
i -= t;
j -= t;
sol += 2 * n;
}
}
}
}
fout << sol;
return 0;
}