Cod sursa(job #2968537)

Utilizator Zed1YasuoAlex Birsan Zed1Yasuo Data 21 ianuarie 2023 14:39:03
Problema Fractal Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.55 kb
#include <fstream>

using namespace std;
ifstream f("fractal.in");
ofstream g("fractal.out");
int k,x,y;
int sol(int k,int x,int y)
{
    if(k==0)
        return 0;
    k--;
    int p=(1<<k);

    if(x<=p&&y<=p)
    {
        return sol(k,y,x);
    }
    else
    if(x>p&&y>p)
    {
        return p*p*2+sol(k,x-p,y-p);
    }
    else
    if(x>p&&y<=p)
    {
        return p*p+sol(k,x-p,y);
    }
    else
    {
        return 3*p*p+sol(k,p*2+1-y,p+1-x);
    }
}
int main()
{
    f>>k>>y>>x;
    g<<sol(k,x,y);
    return 0;
}