Pagini recente » Cod sursa (job #1077526) | Cod sursa (job #3170101) | Cod sursa (job #1274122) | Cod sursa (job #305913) | Cod sursa (job #1738523)
#include <fstream>
using namespace std;
int k, i, j, x, y, sol, n;
int main () {
ifstream fin ("fractal.in");
ofstream fout("fractal.out");
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;
}