A11798 | Nastya Studies Informatics
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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](https://en.wikipedia.org/wiki/Greatest_common_divisor) of $a$ and $b$ , and $LCM(a,b)$ denotes the [least common multiple](https://en.wikipedia.org/wiki/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$ .
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](https://en.wikipedia.org/wiki/Greatest_common_divisor) of $a$ and $b$ , and $LCM(a,b)$ denotes the [least common multiple](https://en.wikipedia.org/wiki/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$ .
输入格式
The only line contains four integers $l,r,x,y$ ( $1<=l<=r<=10^{9}$ , $1<=x<=y<=10^{9}$ ).
输出格式
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$ .
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$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted