Cod sursa(job #783813)

Utilizator al.mocanuAlexandru Mocanu al.mocanu Data 4 septembrie 2012 09:53:41
Problema Fractal Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.47 kb
#include <fstream>
using namespace std;

ifstream f("fractal.in");
ofstream g("fractal.out");

int k;
long long x,y,n=0,aux,t,p;

int main()
{f>>k>>x>>y;
t=1<<(k-1);
p=t*t;

if(x<=t&&y<=t)
{aux=x;
x=y;
y=aux;
    k--;
}

if(x<=t&&y>t)
{
    y=y-t;
    n=n+p;
    k--;
}

if(x>t&&y>t)
{
    x=x-t;
    y=y-t;
    n=n+2*p;
    k--;
}

if(x>t&&y<=t)
{aux=x;
    x=t-y+1;
    y=2*t-aux+1;
    n=n+3*p;
    k--;
}


g<<n;

    return 0;
}