問題一覧 > 通常問題

No.368 LCM of K-products

レベル : / AI推定難易度 : 1050 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 146
作問者 : 🍡yurahuna / テスター : 🐬hec
お気に入りにしたユーザー ProblemId : 1048 / 自分の提出
問題文最終更新日: 2026-06-25 19:04:29
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 136 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。