Problem G

Couple-Bachelor-Spinster Numbers

Input: standard input

Output: standard output

Time Limit: 2 seconds


Can any number be expressed as a subtraction of two squares? The numbers, which can be expressed in such a way, are called square-couple numbers. Your job is to find out


a)      If a number is square couple number.

b)      If the number is square couple then find that format.

c)      Find out how many square couple numbers are there within a certain range (including the terminal numbers).



Each set of input is given in a single line. Each input set may contain one or two signed 32 bit integer numbers. Input is terminated by end of file.



If there is only a single number N in a single line then print two non-negative integer numbers a and b, such that a*a-b*b = N. If the number cannot be expressed in such a format then print the line “Bachelor Number.” in a single line if such number is even and print the line “Spinster Number.” if the number is odd.


If there are two numbers n1 and n2 in the input then print how many bachelor numbers are within n1 and n2 (including n1 and n2). Note that (n1n2 and (n2- n1)<=1000000).


Sample Input:


Sample Output:

Bachelor Number.
4 2
2 1

Shahriar Manzoor


“If all the sides of a cube were identical, how could we tell which side is face up?”