#CCBOTPBA0000057. Chu kỳ máy phát (Generator Synchronization Cycle)
Chu kỳ máy phát (Generator Synchronization Cycle)
Generator Synchronization Cycle
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Two generators have positive integer periods and . They start together at time . The first generator returns to its start at times and the second at . Find the first positive integer time when both return simultaneously. Time is excluded.
Input
One line contains two positive integers and , the two periods, in this order.
Output
Print the smallest positive integer divisible by both and .
Subtasks
- Subtask 1 (20%): .
- Subtask 2 (30%): .
- Subtask 3 (50%): .
Examples
Example 1
Input:
4 6
Output:
12
Explanation: The first returns at 4, 8, 12, ...; the second at 6, 12, 18, ... . Their first common positive time is 12.
Example 2
Input:
7 7
Output:
7
Explanation: The periods are both 7. Their first simultaneous positive return is at time 7.
Example 3
Input:
1 10000
Output:
10000
Explanation: A period-1 generator returns at every positive integer time. The other first returns at 10000, which is therefore their first common positive time.