Pagini recente » Cod sursa (job #1791774) | Istoria paginii runda/brasov_12_jr/clasament | Cod sursa (job #170945) | Cod sursa (job #1009754) | Cod sursa (job #1380164)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fractal.in");
ofstream fout("fractal.out");
int k,x,y,i,nod,mij,z,o;
int main()
{
fin >>k>>x>>y;
z=k;
for(i=1;i<=z;i++)
{
mij=1<<(k-1);
if (x<=mij&&y<=mij)//sectiunea 1
{
o=x;
x=y;
y=o;
}
else
if(x>mij&&y<=mij)//sectiunea 2
{
nod+=3*mij*mij;
x=x-mij;
}
else
if(x<=mij&&y>mij)//sectiunea 3
{
nod+=mij*mij;
o=x;
x=2*mij-y+1;
y=mij-o+1;
}
else//sectiunea 4
{
nod+=2*mij*mij;
x=x-mij;
y=y-mij;
}
k--;
}
fout << nod;
return 0;
}