Pagini recente » Monitorul de evaluare | Cod sursa (job #174540) | Profil WilIiamper | Cod sursa (job #706540) | Cod sursa (job #641574)
Cod sursa(job #641574)
#include <fstream>
using namespace std;
ifstream f("fractal.in");
ofstream g("fractal.out");
int n , x , y , k = 1 , i;
int calc( int k, int x, int y )
{
if ( k == 0 )
return 0;
if ( ( x <= k ) && ( y <= k ) )
return calc (k / 2 , y, x );
if ( ( x > k ) && ( y <= k ) )
return k * k + calc ( k / 2 , x - k , y );
if ( ( x > k ) && ( y > k ) )
return 2 * k * k + calc ( k / 2 , x - k , y - k );
if ( ( x <= k ) && ( y > k ) )
return 3 * k * k + calc ( k / 2 , 2 * k - y + 1 , k - x + 1 );
}
int main()
{
f >> n >> x >> y;
for ( i = 1 ; i <= n - 1 ; i++ )
k *= 2;
g << calc ( k , x , y );
return 0;
}