P15419 [CodeChef] COUNTING
提高+
题目描述

Given two integers A and B, find the count of integers $X \in$ [L, R] such that at least one of the following is true:
X and A are [coprime]
X and B are [coprime]

------ Input Format ------

  • The first and only line of input contains four integers A,B,L, and R: as given in the problem statement.

------ Output Format ------

  • Print a single integer denoting the count of integers X satisfying the condition.

------ Constraints ------

$1 ≤ A,B ≤ 10^{9}$
$1 ≤ L ≤ R ≤ 10^{18}$

----- Sample Input 1 ------
6 15 1 10

----- Sample Output 1 ------
6

----- explanation 1 ------
There are $6$ numbers that satisfy the condition: $1,2,4,5,7,8$.

----- Sample Input 2 ------
235714494 193478285 2 100000000000

----- Sample Output 2 ------
65435081000

----- explanation 2 ------

输入格式

见题面

输出格式

见题面

样例输入
6 15 1 10
样例输出
6