Cod sursa(job #1026468)
Utilizator | Chichirim George george_stelian | Data | 11 noiembrie 2013 17:36:31 |
---|---|---|---|
Problema | Fractal | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.82 kb |
#include <cstdio>
using namespace std;
long long int s;
int k,x,y,a,q;
int main()
{
freopen("fractal.in", "r", stdin);
freopen("fractal.out", "w", stdout);
scanf("%d%d%d",&k,&y,&x);
a=1<<k;
for(;k;k--)
{
if(x<=a/2 && y<=a/2)
{
q=x;x=y;y=q;
}
else
if(x>a/2 && y<=a/2)
{
x-=a/2;
s+=1<<(k-1)*2;
}
else
if(x>a/2 && y>a/2)
{
x-=a/2;
y-=a/2;
s+=2*(1<<(k-1)*2);
}
else
if(x<=a/2 && y>a/2)
{
q=x;
x=a-y+1;
y=a/2-q+1;
s+=3*(1<<(k-1)*2);
}
a>>=1;
}
printf("%lld",s);
fclose(stdin);fclose(stdout);
return 0;
}