Pagini recente » Cod sursa (job #3195120) | Cod sursa (job #748211) | Cod sursa (job #1593081) | Cod sursa (job #1341988) | Cod sursa (job #815271)
Cod sursa(job #815271)
#include <fstream>
using namespace std;
ifstream fin("fractal.in");
ofstream fout("fractal.out");
int power(int a, int b)
{
int or_a=a;
if(b==0)
return 1;
if(b==1)
return a;
for(int i=1;i<b;i++)
a*=or_a;
return a;
}
int round_up(int a)
{
int i=0;
while(a>power(2,i))
i++;
return i;
}
int main()
{
int x,y,k,square_size;
fin>>k>>x>>y;
int steps = 3;
for(int i=2;i<k;i++)
{
steps*=4;
}
steps+=3;
if(k==1)
fout<<0;
else
{
int pow;
pow = power(2,k);
if(x<=pow/2)
{
if(y<=pow/2)
steps-=3;
else
steps-=2;
}
if(x>=pow/2+1)
{
if(y>=pow/2+1)
steps--;
}
fout << steps;
}
}