#include #include #include #include using namespace std; #define int long long typedef priority_queue, greater > Queue; const int kMOD = 1000 * 1000 * 1000 + 7; const int kMAX_N = 1010; const int kMAX_K = 1010; int N, K; int a[kMAX_N]; int GCD(int a, int b) { if (b == 0) return a; else return GCD(b, a % b); } int LCM(int a, int b) { return a * b / GCD(a, b); } map PrimeFactors(int n) { map res; for (int i = 2; i * i <= n; i++) { while (n % i == 0) { res[i]++; n /= i; } } if (n != 1) res[n] = 1; return res; } void Solve() { map biggest_factors; for (int i = 0; i < N; i++) { map factors = PrimeFactors(a[i]); for (map::iterator it = factors.begin(); it != factors.end(); it++) { if (biggest_factors.find(it->first) == biggest_factors.end()) { biggest_factors[it->first] = Queue(); } if (biggest_factors[it->first].size() < K) { biggest_factors[it->first].push(it->second); } else if (biggest_factors[it->first].top() < it->second) { biggest_factors[it->first].pop(); biggest_factors[it->first].push(it->second); } } } int answer = 1; for (map::iterator it = biggest_factors.begin(); it != biggest_factors.end(); it++) { while (!it->second.empty()) { int exponent = it->second.top(); it->second.pop(); for (int i = 0; i < exponent; i++) { answer *= it->first; answer %= kMOD; } } } cout << answer << endl; } signed main() { cin >> N >> K; for (int i = 0; i < N; i++) { cin >> a[i]; } Solve(); return 0; }