Site Planning
Time limit2sMemory limit512 MB
Count quadruples of positive integers (a,b,c,d) with a*b - c*d = n, a>c, b>d, and a,b both different from x.
- Level
Medium6 of 10
- Topics
- Math, Number theory, Brute force, Implementation
- Solved
- No attempts yet
Problem
Scientists are planning a site for a testing ground. The site must be an rectangle, and the testing ground must be a rectangle. The scientists have not settled on the exact values of , , , and , but they know the following.
- The side lengths must be positive integers expressed in kilometers.
- For the safety of the experiment, the width and height of the site must differ from , that is, and must hold.
- The site will be enclosed by a fence, and the testing ground must fit entirely inside the site, that is, and must hold.
- The area of the site not occupied by the testing ground must be exactly square kilometers, that is, must hold.
The scientists want to know how many ways they can choose suitable values of , , , and . Write a program that, given and , determines the number of ways to choose , , , and so that all the conditions above hold.
Input
The first line of input contains two numbers: , the area of the free part of the site without the testing ground , and , the forbidden side length of the site .
A value of means there are no restrictions on the side lengths, since the side lengths must be positive integers and therefore greater than 0.
Output
On a single line, output the number of ways to choose , , , and so that all the conditions hold.
Hint
In the first test example, only fits the conditions.
In the second test example, the following fit the conditions.
- ;
- ;
- ;
- ;
- .
In the third test example, the following fit the conditions.
- ;
- .
In the remaining answers from the previous test, either or equals 3.