#CT0000070. Bội số riêng (Exclusive Multiples)
Bài tập này chưa được xếp vào lộ trình.
Mục lục đề ⌄
Bội số riêng (Exclusive Multiples)
Exclusive Multiples
Version: Phuoc Hung OJ Extended
Problem Statement
Consider all integers in the inclusive interval and two positive integers and .
An integer is an exclusive multiple of and if it is divisible by exactly one of them: either by but not , or by but not . Integers divisible by both, or by neither, are not counted.
Task: Count the integers satisfying that are exclusive multiples of and .
Input
One line containing four positive integers , , , and , in that order.
Output
Print one integer: the number of exclusive multiples in .
Subtasks
- Subtask 1 (30 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (40 points): ; .
Examples
Example 1
Input
1 30 4 6
Output
8
Explanation
The multiples of in the interval are ; those of are . Remove and because both divisibility conditions hold. Exactly eight numbers remain: .
Example 2
Input
10 20 2 3
Output
5
Explanation
The integers divisible by exactly one of and are . The integers and are multiples of both and therefore excluded.
Example 3
Input
1 12 4 4
Output
0
Explanation
Since , any multiple of is also a multiple of . No integer is divisible by exactly one, so the answer is .
Liên quan
Trong các cuộc thi sau: