5.3 ðŸŒŸ ðŸ”¢ Counting Good Pairs ðŸ”¢ ðŸŒŸ

Score: 20pts

Time Limit: 5.00 sec

You are given 2 integers l and r

You need to find the number of good pairs

A pair (a, b) is good if l <= a, b <= r and gcd(a, b) == x and lcm(a, b) == y

You need to find the number of good pairs

A pair (a, b) is good if l <= a, b <= r and gcd(a, b) == x and lcm(a, b) == y

Constraints

values accepted as integers (all less than 10^9)

Input Format

4 integers

l, r, x, y

l, r, x, y

Output Format

Number of pairs

Example 1

Input:

1 12 1 12

Output:

4

Explanation:

Number of pairs -> (1, 12), (12, 1), (3, 4), (4, 3)

1 12 1 12

Output:

4

Explanation:

Number of pairs -> (1, 12), (12, 1), (3, 4), (4, 3)