1. 
/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
* Problem: 155 - All Squares
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=3&page=show_problem&problem=91
*
* @author Evgeni Pavlidis
* @version 1.0, 06/02/2010
*
* Method : Recursion
* Status : Accepted
* Runtime: 0.224
*/

import java.io.*;
import java.util.*;

class Main {

public static final int WIDTH = 2048;
public static final int HEIGHT = 2048;

private static double x,y;


private static int backtrack(int k, int mx, int my)
{
if(k < 1 || mx < 0 || my < 0 || mx > WIDTH || my > HEIGHT)
return 0;

int sum = 0;

int lx,uy, rx, ly;
lx = mx-k;
uy = my-k;
rx = mx+k;
ly = my+k;

if(x >= lx && x <= rx && y >= uy && y <= ly)
sum = 1;

sum += backtrack(k/2, lx, ly);
sum += backtrack(k/2, lx, uy);
sum += backtrack(k/2, rx, ly);
sum += backtrack(k/2, rx, uy);

return sum;
}

public static void main(String...args)
{
Scanner sc = new Scanner(System.in);
int k;

while(true)
{
k = sc.nextInt();
x = sc.nextDouble();
y = sc.nextDouble();

if(k == 0 && x == 0 && y == 0)
break;

System.out.printf("%3d\n", backtrack(k, 1024,1024));
}
}
}