Cod sursa(job #2343849)

Utilizator dorupopDoru Pop dorupop Data 14 februarie 2019 13:28:10
Problema Fractal Scor 80
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.97 kb
#include <fstream>

using namespace std;
ifstream fin("fractal.in");
ofstream fout("fractal.out");
int n,x,y,l,i;
int main()
{


        fin>>l>>y>>x;
        int nr=0;
        l=1<<l;
      while(x>1||y>1)
      {
          l=l/2;
          if(x<=l&&y<=l)
                  swap(x,y);
          else
            if(x>l&&y<=l)
          {
                nr=nr+l*l;
                x=x-l;
          }
          else
          if(x>l&&y>l){
            nr=nr+2*l*l;
             x-=l;y-=l;
          }
          else
          {
                nr=nr+3*l*l;
                y=y-l;
                if(x>l/2&&y>l/2){
                  x=l/2-x+1;
                  y=l/2-y+1;
                }
                else
                if( x<=l/2&&y<=l/2){
                 // x=(l/2+x);
                  //y=(l/2+y);
                  x=l-x+1;
                  y=l-y+1;
                }



          }

      }
      fout<<nr;

    return 0;
}