Pagini recente » Cod sursa (job #2023524) | Cod sursa (job #2161458) | Cod sursa (job #1066774) | Cod sursa (job #1519906) | Cod sursa (job #3348318)
#include <stdio.h>
unsigned long long functie(int ordin_crt, int a, int b){
if( ordin_crt == 0) return 0;
unsigned long long L = 1LL << (ordin_crt - 1);
unsigned long long pasi_crt = L * L;
if( a <= L && b <= L ) return functie(ordin_crt - 1, b, a);
if( a <= L && b > L ) return pasi_crt + functie(ordin_crt - 1, a, b - L);
if( a > L && b > L ) return 2 * pasi_crt + functie(ordin_crt - 1, a - L, b - L);
return 3 * pasi_crt + functie(ordin_crt - 1, L - b + 1, 2 * L - a + 1);
}
int main(){
FILE* fin = fopen("fractal.in", "r");
FILE* fout = fopen("fractal.out", "w");
int k, x, y;
fscanf(fin, "%d %d %d", &k, &x, &y);
unsigned long long pasi = functie(k, x, y);
fprintf(fout, "%llu", pasi);
return 0;
}