P30028 [洛谷] [ROIR 2020 Day2] Regional Planning
入门
题目描述

Problem Description

Translated from ROIR 2020 Day2 T2. Planirovka uchastka, translated by Alpha1022

Translator's note: Due to the original problem statement being somewhat difficult for the translator to understand, the problem's 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\), calculate the number of valid combinations for \(a, b, c, d\).

Input Format

The first line contains two integers \(n, x\).
If \(x = 0\), the second condition is ignored.

Output Format

Output a single line representing the number of valid combinations for \(a, b, c, d\).

Sample Input and Output

Sample Input #1

3 0

Sample Output #1

1

Sample Input #2

5 0

Sample Output #2

5

Sample Input #3

5 3

Sample Output #3

2

Notes/Hints

Sample 1 Explanation

Only \(a = 2, b = 2, c = 1, d = 1\) is valid.

Sample 2 Explanation

The following combinations 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 combinations are valid:
- \(a = 2, b = 4, c = 1, d = 3\);
- \(a = 4, b = 2, c = 3, d = 1\).

Data Range

For \(100\%\) of the data, \(1 \le n \le 3000, 0 \le x \le 3000\).
The specific data constraints are as follows:

Subtask Number Score 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\)
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 0
样例输出
1