Pagini recente » Cod sursa (job #2032732) | Cod sursa (job #1659431) | Cod sursa (job #2140374) | Cod sursa (job #2819848) | Cod sursa (job #1941507)
#include <fstream>
using namespace std;
long long k,x,y,L,sol;
ifstream fin ("fractal.in");
ofstream fout ("fractal.out");
int main (){
// 1 4
// 2 3
fin>>k>>x>>y;
L = (1<<k);
swap (x,y);
while (L!=1){
L/=2;
if (x <= L){
if (y > L){
sol += 3*L*L; // merge 3 cadrane pana acolo (e in 4)
x = 2*L-y+1;
y = L-x+1;
continue;
}
swap (x,y);
continue;
}
if (y <= L){
sol += L*L; // un cadran
x -= L;
continue;
}
sol += L*L*2; // doua cadrane
x -= L;
y -= L;
}
fout<<sol;
return 0;
}