#K61012. Return to Initial Position

    ID: 31215 Type: Default 1000ms 256MiB

Return to Initial Position

Return to Initial Position

You are given a circular track of length \(K\) and \(N\) runners starting at specified positions on the track. In each round, every runner completes one full lap. The problem asks you to determine the minimum number of rounds required so that all runners are back to their exact initial positions.

It can be mathematically shown that regardless of the starting positions, every runner will return to its initial location after exactly \(K\) rounds. Hence, the answer is \(K\).

inputFormat

The input is provided in a single line:

N K a1 a2 ... aN

Where:

  • \(N\) is the number of runners.
  • \(K\) is the length of the circular track (also representing the number of rounds required for a complete lap).
  • \(a_1, a_2, \ldots, a_N\) are the starting positions of the runners on the track.
  • outputFormat

    Output a single integer representing the minimum number of rounds required for all runners to return to their initial positions.

    ## sample
    3 5 1 3 5
    5