Cod sursa(job #1942075)

Utilizator Liviu_Ionut_MoantaMoanta Ionut Liviu Liviu_Ionut_Moanta Data 27 martie 2017 19:44:43
Problema Fractal Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.88 kb
#include<fstream>
using namespace std;
ifstream fin("fractal.in");
ofstream fout("fractal.out");
int x,y,q1,x1,y1,c,q,sol;
int main(){
    fin>>c>>y>>x;
    q=(1<<c);
    while(q!=1){
        q1=q/2;
        if(x<=q1){
            if(y<=q1){
                x1=y;
                y1=q1-x+1;
                x=x1;
                y=y1;
                y=q1-y+1;

            }
            else{
                sol+=3*q1*q1;
                y-=q1;
                x1=q1-y+1;
                y1=x;
                x=x1;
                y=y1;
                y=q1-y+1;
            }
        }
        else{
            if(y<=q1){
                sol+=q1*q1;
                x-=q1;
            }
            else{
                sol+=2*q1*q1;
                x-=q1;
                y-=q1;
            }
        }
        q/=2;
    }
    fout<<sol;
    return 0;
}