← Practice problem bank

Jan 6, 2026

Chrono-Sync: The Modular Clock Challenge

Daily Challenge Archive · Open

mediummath

150 pts · 10000 ms · 128 MB · Practice only

Problem

Welcome to the Chrono-Sync challenge! In this alternate universe, time is regulated by a series of modular clocks, each with a unique modulus. Your mission is to determine the least number of ticks required to align all clocks so they display zero simultaneously. Here's a step-by-step guide to tackle this challenge: 1. **Understand the Setup**: Each clock operates mod its unique base, meaning it ticks from 0 up to its modulus-1, and then resets to 0. Your goal is to find the smallest time (in ticks) at which all clocks show 0 simultaneously. 2. **Input Format**: You will be given a list of integers, where each integer represents the modulus of a clock. For example, if the input is [3, 5, 7], you have three clocks with moduli 3, 5, and 7. 3. **Determine Synchronization Time**: Calculate the minimum common multiple (LCM) of all given moduli, as this represents the earliest time when all clocks will align at zero. 4. **Examples**: - Given the moduli [3, 4], the clocks tick as follows: Clock 1 (mod 3) cycles through [0, 1, 2] and Clock 2 (mod 4) cycles through [0, 1, 2, 3]. They both show 0 at the 12th tick, which is the LCM of 3 and 4. - Edge Case: If all moduli are 1, the clocks are always synchronized at 0. 5. **Hints**: - **Approach Suggestions**: Consider how the least common multiple of numbers relates to their synchronization. - **Algorithm/Data Structure Hints**: Implementing a function to calculate the LCM of two numbers could be a cornerstone of your solution. - **Edge Cases to Consider**: What happens if all moduli are the same? What if some moduli are prime numbers? - **Optimization Tips**: Think about how you can efficiently compute the LCM for more than two numbers without repeated calculations. Dive into the world of Chrono-Sync and enjoy the challenge of bringing order to a universe of ticking clocks!

Input format

The first line contains a single integer n, the number of clocks. The second line contains n space-separated integers, where each integer represents the modulus of a clock.

Output format

Output a single integer, the smallest number of total ticks required to synchronize all clocks to zero.

Constraints

1 <= n <= 100. 2 <= modulus <= 10^9.

Sample input

3
3 4 5

Sample output

60

Sign in to submit solutions

Run your code against all test cases and get instant feedback.

Sign in