#P15523. [ROIR 2015 Day 1] hall 选择大厅

    ID: 17543 远端评测题 1000ms 256MiB 尝试: 0 已通过: 0 显示难度普及− 上传者: 标签>数学2015ROIR(俄罗斯)

[ROIR 2015 Day 1] hall 选择大厅

Problem 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 AA and BB square meters (including AA and BB).

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 CC and DD meters (including CC and DD).

Before making the final choice, the organizers plan to check every hall that meets the size requirements. A hall of size Y×ZY \times Z is considered the same as a hall of size Z×YZ \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 AA, BB, CC, and DD, computes the number of distinct hall sizes that satisfy the requirements.

Input Format

The input file contains four integers separated by spaces: AA, BB, CC, and DD (1≤A≤B≤1091 \leq A \leq B \leq 10^9, 4≤C≤D≤1094 \leq C \leq D \leq 10^9).

Output Format

The output file should contain one integer — the number of halls that satisfy the conditions.

2 10 4 8
3

Hint

Explanation of the Example

In this example, the hall sizes that satisfy the constraints are: 1×21 \times 2, 1×31 \times 3, 2×22 \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 2525 tests, and each test is worth 22 points. Each test is scored independently.

Translation source: GPT 5.2.

Translated by ChatGPT 5