Cod sursa(job #1688739)
| Utilizator | Data | 13 aprilie 2016 18:21:50 | |
|---|---|---|---|
| Problema | Fractal | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.52 kb |
#include <fstream>
using namespace std;
ifstream fin("fractal.in");
ofstream fout("fractal.out");
int x, y, K;
int construire(int x, int y, int K)
{
if (K==1)
return 0;
K/=2;
if (y<=K && x<=K)
return construire(y, x, K);
if (x<=K)
return construire(K-(y-K)+1, K-x+1, K)+3*K*K;
if (y<=K)
return construire(x-K, y, K)+K*K;
return construire(x-K, y-K, K)+2*K*K;
}
int main()
{
fin >> K >> y >> x;
fout << construire(x, y, 1 << K);
return 0;
}
