#C11435. Minimum Reading Factor
Minimum Reading Factor
Minimum Reading Factor
You are given N students and M books. Each book has a difficulty rating. In order that every student can read a book with difficulty exactly a multiple of some factor F, you must determine the minimum possible value of F such that every book's difficulty is a multiple of F
.
Mathematically, if the difficulty ratings are given by \(d_1, d_2, \dots, d_M\), then the required factor \(F\) is:
\[ F = \gcd(d_1, d_2, \dots, d_M) \]For example, if the difficulties are [3, 6, 9, 12, 18], then \(F = 3\) since 3 is the greatest common divisor of all values. Your task is to compute this minimum factor.
inputFormat
The input is read from stdin and consists of two lines. The first line contains two integers N and M, where N is the number of students and M is the number of books. The second line contains M space-separated integers representing the difficulty ratings of each book.
Note: Although N is provided, the solution does not directly depend on it.
outputFormat
Output a single integer to stdout: the minimum factor F (i.e. the greatest common divisor of the book difficulties).
## sample4 5
3 6 9 12 18
3