Cod sursa(job #1219834)
| Utilizator | Data | 15 august 2014 13:24:22 | |
|---|---|---|---|
| Problema | Fractal | Scor | 30 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.69 kb |
using namespace std;
#include <fstream>
ifstream fin("fractal.in");
ofstream fout("fractal.out");
int main()
{
int k, xf, yf, rez = 0;
fin >> k >> xf >> yf;
while(k > 0)
{
--k;
if(yf <= (1 << k))
{
if(xf <= (1 << k)) swap(xf, yf);
else
{
rez += 3 * (1 << (2 * k));
xf -= (1 << k);
}
}
else
{
if(xf <= (1 << k)) rez += (1 << (2 * k)), yf = 2 * (1 << k) - yf + 1, xf = (1 << k) - xf + 1;
else rez += 2 * (1 << (2 * k)), xf -= (1 << k), yf -= (1 << k);
}
}
fout << rez << '\n';
return 0;
}
