P15523 [ROIR 2015 Day 1] hall Choosing a Hall.
Description
To hold the opening ceremony of the Informatics Olympiad, the organizers need to choose a suitable hall. The hall must be rectangular, and the length of each side must be a positive integer.
To fit all participants in the hall and also avoid making the hall look too empty, the area should be between $A$ and $B$ square meters (including $A$ and $B$).
To put up posters on the hall walls to show students' results in the contest, and at the same time avoid making people feel there are too few results, the perimeter of the hall should be between $C$ and $D$ meters (including $C$ and $D$).
Before making the final choice, the organizers plan to check every hall that meets the size requirements. A hall of size $Y \times Z$ is considered the same as a hall of size $Z \times Y$. To understand the amount of work needed to review the halls, the organizers ask: how many different halls satisfy the above constraints.
**Task**: Write a program that, given $A$, $B$, $C$, and $D$, computes the number of distinct hall sizes that satisfy the requirements.
Input Format
The input file contains four integers separated by spaces: $A$, $B$, $C$, and $D$ ($1 \leq A \leq B \leq 10^9$, $4 \leq C \leq D \leq 10^9$).
Output Format
The output file should contain one integer — the number of halls that satisfy the conditions.
Explanation/Hint
### Explanation of the Example
In this example, the hall sizes that satisfy the constraints are: $1 \times 2$, $1 \times 3$, $2 \times 2$.
### Grading System and Subtask Description
#### Subtask 1 (50 points)
$1 \leq A \leq B \leq 1000, 4 \leq C \leq D \leq 1000$.
You get points only if all tests pass.
#### Subtask 2 (50 points)
$1 \leq A \leq B \leq 10^9, 4 \leq C \leq D \leq 10^9$.
This subtask has $25$ tests, and each test is worth $2$ points. Each test is scored independently.
Translation source: GPT 5.2.
Translated by ChatGPT 5