Cod sursa(job #2200082)

Utilizator Teodor_ICT2Teodor Melega Teodor_ICT2 Data 30 aprilie 2018 12:00:46
Problema Fractal Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.69 kb
#include <bits/stdc++.h>
 
using namespace std;
 
 
int t;
 
void fr(int x, int y, int k){
    if (k==1){
        return;
    }
    k>>=1;
    if (x<=k){
        if (y<=k){
            fr(y,x,k);
        }
        else{
            t+=k*k;
        fr(x,y-k,k);
        }
    }
    else{
        if (y<=k){
            t+=k*k*3;
            fr(k-y+1,2*k-x+1,k);
        }
        else{
            t+=2*k*k;
            fr(x-k,y-k,k);
        }
    }
}
 
int main()
{
    freopen("fractal.in","r",stdin);
    freopen("fractal.out","w",stdout);
 
    int n,x,y,k=1,i;
 
    scanf("%d%d%d",&n,&x,&y);
    k=1<<n;
    fr(x,y,k);
 
    printf("%d",t);
    return 0;
}