Pagini recente » Cod sursa (job #3342935) | Cod sursa (job #3353449) | Cod sursa (job #3337876) | Cod sursa (job #3355017) | Cod sursa (job #3338440)
#include<bits/stdc++.h>
using namespace std;
ifstream fin("fractal.in");
ofstream fout("fractal.out");
int main(){
int k, x, y, l, ans=0;
fin >> k >> x >> y;
l = (1<<k);
while(l){
l = l/2;
if(x<=l && y<=l){
/// cadranul 1 (din problema)
swap(x, y);
continue;
}
if(x<=l && y > l){
/// cadranul 2
ans += l*l;
y = y-l;
continue;
}
if(x>l && y>l){
/// cadranul 3
ans += 2*l*l;
x -= l;
y -= l;
continue;
}
/// cadranul 4
ans += 3*l*l;
x -= l;
x = l-x+1;
y = l-y+1;
swap(x, y);
}
fout << ans;
}