Pagini recente » Borderou de evaluare (job #1793599) | Cod sursa (job #231104) | Cod sursa (job #3351707) | Cod sursa (job #1150183) | 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;
}