No.368 LCM of K-products
Problem Statement
There is a sequence $A = \{a_1, a_2, \dots, a_N\}$ consisting of $N$ positive integers.
Let $B$ be the set of products of $K$ elements of $A$ with distinct indices.
Find the least common multiple of all elements of $B$, modulo $10^9 + 7$.
Input
$N$ $K$ $a_1$ $a_2$ ... $a_N$
The first line contains the number of elements $N (1 \leq N \leq 1000)$ of the sequence $A$ and $K (1 \leq K \leq N )$ as space-separated integers.
The second line contains the elements $a_i (1 \leq i \leq N, 1 \leq a_i \leq 10^9)$ of the sequence $A$ as space-separated integers.
Output
Output the answer on one line, followed by a newline.
Sample
Sample 1
Input
3 2 2 3 5
Output
30
In this example, $B = \{ a_1 \times a_2, a_1 \times a_3, a_2 \times a_3 \} = \{6, 10, 15\}$.
The least common multiple of all elements of $B$ is 30.
Sample 2
Input
3 2 2 4 8
Output
32
$B = \{8, 16, 32\}$.
Sample 3
Input
4 3 2 2 2 2
Output
8
$B = \{ a_1 \times a_2 \times a_3, a_1 \times a_2 \times a_4, a_1 \times a_3 \times a_4, a_2 \times a_3 \times a_4 \} = \{8, 8, 8, 8\}$.
Pay attention to how $B$ is constructed.
Sample 4
Input
3 1 2016 4 11
Output
22176
Since $K = 1$, $B = \{ a_1, a_2, a_3 \} = \{2016, 4, 11\}$.
Sample 5
Input
10 7 832 223 29375 10 447239 999299573 5272 829829 6265 33
Output
738866291
Output the remainder when divided by $10^9 + 7$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
🍡yurahuna
🐬hec