Mai intai trebuie sa te autentifici.
Cod sursa(job #1661518)
Utilizator | Data | 23 martie 2016 22:26:47 | |
---|---|---|---|
Problema | Fractal | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.49 kb |
#include <fstream>
#include <iostream>
using namespace std;
ifstream f("fractal.in");
ofstream fg("fractal.out");
int n,x,y;
int solve(int n, int x, int y)
{
if(n==0)
return 0;
n--;
int len= 1 << n;
if(x<=len&&y<=len)
return solve(n,y,x);
if(x>len&&y<=len)
return len*len+solve(n,x-len,y);
if(x>len&&y>len)
return 2*len*len+solve(n,x-len,y-len);
return 3*len*len+solve(n,2*len-y+1,len-x+1);
}
int main()
{
f>>n>>y>>x;
g<<solve(n,x,y);
}