Cod sursa(job #1738523)

Utilizator mariusn01Marius Nicoli mariusn01 Data 6 august 2016 21:57:01
Problema Fractal Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.92 kb
#include <fstream>

using namespace std;

int k, i, j, x, y, sol, n;

int main () {

    ifstream fin ("fractal.in");
    ofstream fout("fractal.out");
    fin>>k>>j>>i;
    int t;

    while (k>0) {
        k--;
        t = (1<<k);
        n = (t)*(t);
        if (i <= t && j<=t) {
            x = j;
            y = t-i+1;
            y = t-y+1;
            i = x;
            j = y;
        } else
            if (i <= t && j > t) {
                j-=t;
                x = t-j+1;
                y = i;
                y = t-y+1;
                i = x;
                j = y;
                sol += (n) * 3;
            } else
                if (i>t && j<=t) {
                    i -= t;
                    sol += n;
                } else {
                    i -= t;
                    j -= t;
                    sol += 2*n;
                }

    }
    fout<<sol;
    return 0;
}