#CT0000144. Hai lịch trực (Two Duty Schedules)
Bài tập này chưa được xếp vào lộ trình.
Mục lục đề ⌄
Hai lịch trực (Two Duty Schedules)
Two Duty Schedules
Version: Phuoc Hung OJ Extended
Problem Statement

At a library, two volunteer groups follow fixed duty schedules. Days are numbered by positive integers starting from .
Group A is on duty on days whose numbers are divisible by . Group B is on duty on days whose numbers are divisible by . Their schedules are independent, so both groups may be on duty on the same day.
Count the days in the inclusive interval on which exactly one of the two groups is on duty. Days with neither group or with both groups must not be counted.
Input
A single line contains four positive integers , , , , in that order.
Output
Print one integer: the number of days in on which exactly one group is on duty.
Subtasks
- Subtask 1 (30 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (40 points): ; .
Examples
Example 1
Input
1 20 4 6
Output
6
Explanation
Group A attends on days and group B on . Day belongs to both schedules and must be excluded. Exactly six days remain: .
Example 2
Input
5 15 3 3
Output
0
Explanation
Both periods are . Every day divisible by in has both groups on duty, and all other days have neither group. Hence the answer is .
Example 3
Input
10 30 4 7
Output
6
Explanation
Multiples of in the interval are ; multiples of are . Day is shared and excluded. The valid days are , giving .
Liên quan
Trong các cuộc thi sau: