Hide

Problem D
BizzFuzz

Languages en sv

Algot was just at an interview at a software company and had to solve the classic FizzBuzz problem. It consists of printing the integers from 1 to 100, but replacing each integer divisible by 3 to "Fizz", each divisible by 5 to "Buzz" and each divisible by both to "FizzBuzz".

He however has a slight variation in mind, and would like you to calculate the number of integers between $A$ and $B$ (inclusive) divisible by both $C$ and $D$.

Input

One row with the integers $A, B, C, D$ such that $1 \leq A \leq B \leq 10^{18}$ and $1 \leq C, D \leq B$ .

Output

One row with the number of $X$ such that $A \le X \le B$ where $C$ divides $X$ and $D$ divides $X$.

Scoring

Your solution will be tested on a number of testgroups. To earn points in a testgroup all tests in it must succeed.

Group

Points

Limits

$1$

$20$

$|B-A| < 1000$

$2$

$20$

$A = 1, C = 1$

$3$

$20$

$D = 2 \cdot C$

$4$

$40$

No further restrictions

Sample Input 1 Sample Output 1
1 20 2 5
2
Sample Input 2 Sample Output 2
1 15 1 3
5
Sample Input 3 Sample Output 3
3 15 3 6
2
Sample Input 4 Sample Output 4
11 121 1 11
11

Please log in to submit a solution to this problem

Log in