Cod sursa(job #1732321)
| Utilizator | Data | 21 iulie 2016 14:27:58 | |
|---|---|---|---|
| Problema | Fractal | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.49 kb |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll f(int x,int y,int k){
if(k < 0) return 0;
if(x <= (1<<k) && y <= (1<<k)) return f(y,x,k-1);
if(x <= (1<<k) && y > (1<<k)) return f(x,y-(1<<k),k-1)+(1LL<<(2*k));
if(x > (1<<k) && y > (1<<k)) return f(x-(1<<k),y-(1<<k),k-1)+2*(1LL<<(2*k));
return f((1<<k)-y+1,2*(1<<k)-x+1,k-1)+3*(1LL<<(2*k));
}
int K,x,y;
int main(){
ifstream cin("fractal.in");
ofstream cout("fractal.out");
cin >> K >> x >> y;
cout << f(x,y,K-1);
}
