Cod sursa(job #1219855)

Utilizator Cristian1997Vintur Cristian Cristian1997 Data 15 august 2014 14:45:05
Problema Fractal Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.68 kb
using namespace std;
#include <fstream>
ifstream fin("fractal.in");
ofstream fout("fractal.out");


int main()
{
    int k, xf, yf, rez = 0, L, aux;
    fin >> k >> xf >> yf;
    while(k > 0)
    {
        --k; L = (1 << k);
        if(yf <= L)
        {
            if(xf <= L) swap(xf, yf);
            else
            {
                rez += 3 * L * L;
                aux = xf;
                xf = L + 1 - yf;
                yf = 2 * L + 1 - aux;
            }
        }
        else
        {
            if(xf <= L) rez += L * L, yf -= L;
            else rez += 2 * L * L, xf -= L, yf -= L;
        }
    }
    fout << rez << '\n';
    return 0;
}