Pagini recente » Cod sursa (job #1767626) | Cod sursa (job #2668141) | Cod sursa (job #580280) | Cod sursa (job #733863) | Cod sursa (job #2343698)
#include <fstream>
using namespace std;
int k, x, y, l, nr;
int main () {
ifstream fin ("fractal.in");
ofstream fout ("fractal.out");
fin>>k>>y>>x;
l=1<<k;
nr=0;
if (k%4==3) {
while (x>1 || y>1) {
l/=2;
if (x<=l && y>l) {
nr+=l*l;
y-=l;
} else if (x>l && y>l) {
nr+=2*l*l;
x-=l;
y-=l;
} else if (x>l && y<=l) {
nr+=3*l*l;
x-=l;
}
}
} else {
while (x>1 || y>1) {
l/=2;
if (x>l && y<=l) {
nr+=l*l;
x-=l;
} else if (x>l && y>l) {
nr+=2*l*l;
x-=l;
y-=l;
} else if (x<=l && y>l) {
nr+=3*l*l;
y-=l;
}
}
}
fout<<nr;
return 0;
}