Cod sursa(job #2814235)

Utilizator biancalautaruBianca Lautaru biancalautaru Data 7 decembrie 2021 20:14:37
Problema Fractal Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.74 kb
#include <fstream>
using namespace std;
ifstream fin("fractal.in");
ofstream fout("fractal.out");
long long n,x,y,l,s,aux;
int main() {
    fin>>n>>x>>y;
    l=1<<n;
    while (l>0) {
        l/=2;
        if (x<=l && y<=l)
            swap(x,y);
        else
            if (x<=l && y>l) {
                s+=l*l;
                y-=l;
            }
            else
                if (x>l && y>l) {
                    s+=2*l*l;
                    x-=l;
                    y-=l;
                }
                else {
                    s+=3*l*l;
                    x-=l;
                    aux=l-x+1;
                    x=l-y+1;
                    y=aux;
                }
    }
    fout<<s;
    return 0;
}