P9788 [ROIR 2020] Area Planning (Day2)
Description
**Translated from [ROIR 2020](http://neerc.ifmo.ru/school/archive/2019-2020.html) Day2 T2.** ***[Планировка участка](http://neerc.ifmo.ru/school/archive/2019-2020/ru-olymp-regional-2020-day2.pdf)***, translated by Alpha1022.
*Translator’s note: Since the original statement was a bit hard for the translator to understand, the meaning is abstracted directly here.*
You have four variables $a,b,c,d$ that must satisfy:
- $a,b,c,d \in \mathbb N^*$.
- $a \ne x, b \ne x$.
- $a > c, b > d$.
- $a \cdot b - c \cdot d = n$.
For given $x,n$, find how many possible assignments of $a,b,c,d$ there are.
Input Format
The first line contains two integers $n,x$.
If $x=0$, it means the second condition is ignored.
Output Format
One line, the number of valid assignments of $a,b,c,d$.
Explanation/Hint
#### Sample 1 Explanation
Only $a=2,b=2,c=1,d=1$ is valid.
#### Sample 2 Explanation
The following assignments are valid:
- $a=2,b=3,c=1,d=1$;
- $a=2,b=4,c=1,d=3$;
- $a=3,b=2,c=1,d=1$;
- $a=3,b=3,c=2,d=2$;
- $a=4,b=2,c=3,d=1$.
#### Sample 3 Explanation
The following assignments are valid:
- $a=2,b=4,c=1,d=3$;
- $a=4,b=2,c=3,d=1$.
#### Constraints
For $100\%$ of the testdata, $1 \le n \le 3000, 0 \le x \le 3000$.
The detailed limits are shown in the table below:
|Subtask ID|Points|Constraints|
|:-:|:-:|:-:|
|$1$|$11$|$1 \le n \le 50, x=0$|
|$2$|$10$|$1 \le n \le 50$|
|$3$|$20$|$1 \le n \le 500, x=0$|
|$4$|$22$|$1 \le n \le 500$|
|$5$|$17$|$1 \le n \le 3000, x=0$|
|$6$|$20$|$1 \le n \le 3000$|
Translated by ChatGPT 5