Pagini recente » Cod sursa (job #3145548) | Cod sursa (job #3270229) | Cod sursa (job #2159179) | Cod sursa (job #1466383) | Cod sursa (job #833292)
Cod sursa(job #833292)
#include <iostream>
#include <fstream>
#include <math.h>
using namespace std;
ifstream in("fractal.in");
ofstream out("fractal.out");
int move(int l, int x, int y)
{
if(l==1) return 0;
l=l/2;
if( x<=l && y<=l )
return move(l,y,x);
else if( x<=l && y>l )
return l*l+move(l,x,y-l);
else if(x>l && y>l)
return 2*l*l+move(l,x-l,y-l);
else return 3*l*l+move(l,l-y+1, 2*l-x+1);
}
int main()
{
int k,x,y,answer;
in>>k>>x>>y;
answer=move((int)pow(2,k),x,y);
out<<answer;
return 0;
}