QOJ.ac

QOJ

时间限制: 1.0 s 内存限制: 1024 MB 总分: 100 可 Hack ✓

#17867. 分数

统计

距离大学修学能力考试(Suneung,即韩国高考)还有大约 44 天。该考试旨在评估学生对国家课程标准的掌握程度以及大学教育所需的学术能力。

该考试的科目之一是数学,由 21 道选择题和 9 道简答题组成。如下面的答题卡所示,每道简答题的答案都保证是 $1000$ 以下的唯一正整数。

然而,命题者可能希望给学生出一些答案非整数的简答题,例如 $2\sqrt{3}$ 或 $\frac{5}{3}$。通常,解决方法是将答案写成规范形式,然后将该形式中的所有整数相加,并要求学生写出相加后的数字。

特别地,当答案是一个正有理数 $\frac{a}{b}$ 时,命题者通常会要求学生将其约分,并写出约分后最简分数的分子与分母之和。例如,当答案为 $\frac{18}{10}$ 时,学生应将其约分为 $\frac{9}{5}$,并写出最终答案 $9 + 5 = 14$。

然而,当答案为 $\frac{521}{500}$ 时,约分后的分数仍然是 $\frac{521}{500}$,因此学生需要写出最终答案 $521 + 500 = 1021$。但这不应该发生,因为简答题的所有答案都必须小于 $1000$。为了避免这种情况,命题者必须确保在约分后,分子与分母之和不超过 $999$。我们称这样的分数为 Suneung 分数。例如,$\frac{1996}{2}$ 和 $\frac{18}{10}$ 是 Suneung 分数,而 $\frac{1998}{2}$ 和 $\frac{521}{500}$ 则不是。

假设今年的一位命题者写了一道题,该题的答案是 $\frac{x}{y}$。由于题目尚未最终确定,我们只知道对于给定的 $A, B, C, D$,满足 $A \le x \le B$ 且 $C \le y \le D$。命题者想要知道,在所有数对 $(x, y)$ 中,有多少个 $\frac{x}{y}$ 是 Suneung 分数。请编写一个程序来计算这个数量。

输入格式

第一行也是唯一的一行包含四个空格分隔的整数 $A, B, C$ 和 $D$($1 \le A \le B \le 10^{12}$,$1 \le C \le D \le 10^{12}$)。

输出格式

输出满足 $A \le x \le B$ 且 $C \le y \le D$ 且 $\frac{x}{y}$ 是 Suneung 分数的整数对 $(x, y)$ 的数量。

样例

输入样例 1

5 8 3 6

输出样例 1

16

输入样例 2

2018 2019 2018 2019

输出样例 2

2

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.