Cod sursa(job #2343736)

Utilizator dorupopDoru Pop dorupop Data 14 februarie 2019 12:02:31
Problema Fractal Scor 70
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.72 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;
                //x=l-x+1;
                //swap(x,y);

          }

      }
      fout<<nr;

    return 0;
}