CF992B.Nastya Studies Informatics
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Today on Informatics class Nastya learned about GCD and LCM (see links below). Nastya is very intelligent, so she solved all the tasks momentarily and now suggests you to solve one of them as well.
We define a pair of integers (a, b) good, if GCD(a, b) = x and LCM(a, b) = y, where GCD(a, b) denotes the greatest common divisor of a and b, and LCM(a, b) denotes the least common multiple of a and b.
You are given two integers x and y. You are to find the number of good pairs of integers (a, b) such that l ≤ a, b ≤ r. Note that pairs (a, b) and (b, a) are considered different if a ≠ b.
今天的信息学课上,娜斯佳学习了最大公约数(GCD)和最小公倍数(LCM)(参见下方链接)。娜斯佳非常聪明,她立刻解决了所有习题,现在她也邀请你来解决其中一道。
我们称一对整数 (a,b) 是“好的”,当且仅当 GCD(a,b)=x 且 LCM(a,b)=y,其中 GCD(a,b) 表示 a 与 b 的最大公约数,LCM(a,b) 表示 a 与 b 的最小公倍数。
给定两个整数 x 和 y,你需要找出满足 l≤a,b≤r 的“好”整数对 (a,b) 的个数。注意:若 a=b,则 (a,b) 与 (b,a) 被视为不同的数对。
输入格式
The only line contains four integers l, r, x, y (1 ≤ l ≤ r ≤ 109, 1 ≤ x ≤ y ≤ 109).
唯一一行包含四个整数 l、r、x、y(1 ≤ l ≤ r ≤ 109,1 ≤ x ≤ y ≤ 109)。
输出格式
In the only line print the only integer — the answer for the problem.
在唯一的一行中输出唯一的整数——该问题的答案。
输入输出样例
输入#1
1 2 1 2
输出#1
2
输入#2
1 12 1 12
输出#2
4
输入#3
50 100 3 30
输出#3
0
说明/提示
In the first example there are two suitable good pairs of integers (a, b): (1, 2) and (2, 1).
In the second example there are four suitable good pairs of integers (a, b): (1, 12), (12, 1), (3, 4) and (4, 3).
In the third example there are good pairs of integers, for example, (3, 30), but none of them fits the condition l ≤ a, b ≤ r.
在第一个例子中,有两对满足条件的好数对整数 (a,b):(1,2) 和 (2,1)。
在第二个例子中,有四对满足条件的好数对整数 (a,b):(1,12)、(12,1)、(3,4) 和 (4,3)。
在第三个例子中,存在好数对整数,例如 (3,30),但其中没有任何一对满足条件 l≤a,b≤r。
输入解题思路,AI测评打分。不知道怎么写?