#CT00043. Bội riêng (Exclusive Multiples)
Bội riêng (Exclusive Multiples)
Exclusive Multiples
Version: Phuoc Hung OJ Extended
Problem Statement
You are given four positive integers with .
An integer is called an exclusive multiple if it is divisible by exactly one of and ; that is, it is divisible by or by , but not by both.
Count the exclusive multiples in the interval .
Input
One line contains four positive integers separated by spaces.
Output
Print one integer: the number of exclusive multiples in .
Subtasks
- Subtask 1 (40%): , .
- Subtask 2 (30%): , .
- Subtask 3 (30%): , .
Examples
Example 1
Input
1 20 4 6
Output
6
Explanation
The valid numbers are . Number is divisible by both and , so it is excluded.
Example 2
Input
10 30 5 10
Output
2
Explanation
The multiples of are . Values are also multiples of , leaving only and .
Example 3
Input
7 9 2 3
Output
2
Explanation
In , number is divisible only by and number only by , so there are two valid numbers.
Liên quan
Trong các cuộc thi sau: