#C3589. Equal Rope Segmentation
Equal Rope Segmentation
Equal Rope Segmentation
You are given a collection of ropes with positive integer lengths. Your task is to determine the maximum possible length L such that each rope can be divided into one or more equal segments of length L without any leftover portion. In mathematical terms, if the rope lengths are given by \(a_1, a_2, \dots, a_n\), you need to find \(L = \gcd(a_1, a_2, \dots, a_n)\). If no ropes are provided (i.e. \(n = 0\)), output 0.
Note: All input and output are handled via stdin and stdout respectively.
inputFormat
The first line contains an integer n representing the number of ropes. If n > 0, the second line contains n space-separated positive integers representing the lengths of the ropes. If n = 0, there is no second line.
outputFormat
Output a single integer representing the greatest common divisor (GCD) of the given rope lengths. If there are no ropes, output 0.
## sample5
4 3 2 5 6
1
</p>