#P9788. [ROIR 2020] 区域规划 (Day2)

[ROIR 2020] 区域规划 (Day2)

Problem Description

Translated from ROIR 2020 Day2 T2. Планировка участка, 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,da,b,c,d that must satisfy:

  • a,b,c,dNa,b,c,d \in \mathbb N^*.
  • ax,bxa \ne x, b \ne x.
  • a>c,b>da > c, b > d.
  • abcd=na \cdot b - c \cdot d = n.

For given x,nx,n, find how many possible assignments of a,b,c,da,b,c,d there are.

Input Format

The first line contains two integers n,xn,x.
If x=0x=0, it means the second condition is ignored.

Output Format

One line, the number of valid assignments of a,b,c,da,b,c,d.

3 0
1
5 0
5
5 3
2

Hint

Sample 1 Explanation

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

Sample 2 Explanation

The following assignments are valid:

  • a=2,b=3,c=1,d=1a=2,b=3,c=1,d=1;
  • a=2,b=4,c=1,d=3a=2,b=4,c=1,d=3;
  • a=3,b=2,c=1,d=1a=3,b=2,c=1,d=1;
  • a=3,b=3,c=2,d=2a=3,b=3,c=2,d=2;
  • a=4,b=2,c=3,d=1a=4,b=2,c=3,d=1.

Sample 3 Explanation

The following assignments are valid:

  • a=2,b=4,c=1,d=3a=2,b=4,c=1,d=3;
  • a=4,b=2,c=3,d=1a=4,b=2,c=3,d=1.

Constraints

For 100%100\% of the testdata, 1n3000,0x30001 \le n \le 3000, 0 \le x \le 3000.
The detailed limits are shown in the table below:

Subtask ID Points Constraints
11 1111 1n50,x=01 \le n \le 50, x=0
22 1010 1n501 \le n \le 50
33 2020 1n500,x=01 \le n \le 500, x=0
44 2222 1n5001 \le n \le 500
55 1717 1n3000,x=01 \le n \le 3000, x=0
66 2020 1n30001 \le n \le 3000

Translated by ChatGPT 5