题库练习 Two Arithmetic Progressions
← 上一题 下一题 →

A10488 | Two Arithmetic Progressions

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

You are given two arithmetic progressions: $a_{1}k+b_{1}$ and $a_{2}l+b_{2}$ . Find the number of integers $x$ such that $L<=x<=R$ and $x=a_{1}k'+b_{1}=a_{2}l'+b_{2}$ , for some integers $k',l'>=0$ .

输入格式

The only line contains six integers $a_{1},b_{1},a_{2},b_{2},L,R \, ( 0 \lt a_1,a_2 \le 2\times10^9,-2\times10^9 \le b_1,b_2,L,R \le 2\times10^9,L \le R)$ .

输出格式

Print the desired number of integers $x$ .

输入输出样例

输入 #1
2 0 3 3 5 21
输出 #1
3
输入 #2
2 4 3 0 6 17
输出 #2
2
C++ 编辑器
输入
输出