1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<iomanip>
#include<fstream>
#include<ctime>
#include<climits>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back

int n, i, tab[30], tab1[20], tabA[20], tabB[20], tabC[20], sizA, sizB, sizC;
LL k, k2, k3, maxx, resA[600005], resB[20005], resC[20005], ind[3];

void go(LL w, int* tt, int p, int siz, LL lim, LL* resTab, int idx) {
	resTab[ind[idx]++] = w;
	for (int i=p;i<siz;i++) {
		LL r = w * tt[i];
		if (r <= lim && (r / tt[i]) == w) go(r, tt, i, siz, lim, resTab, idx);
	}
}

bool rozloz(LL k) {
	for (int i=0;i<n;i++) while (k % tab[i] == 0) {
		k /= tab[i];
	}
	return k == 1;
}

void check(LL* small, LL* medium, int idxSmall, int idxMedium) {
	int i, j, idx;
	LL dz, lim;
	for (i=0;i<ind[idxSmall];i++) {
		if (small[i] > k3) break;
		lim = (LL)sqrt(k / small[i]) + 1;
		for (j = 0;j<ind[idxMedium];j++) {
			if (medium[j] > lim) break;
			dz = small[i] * medium[j];
			idx = lower_bound(resA, resA + ind[0], k / dz) - resA;
			if (idx >= ind[0] || resA[idx] * dz > k || resA[idx] * dz / dz != resA[idx]) idx--;
			maxx = max(maxx, resA[idx] * dz);
		}
	}
}

void check() {
	sort(resA, resA + ind[0]);
	sort(resB, resB + ind[1]);
	sort(resC, resC + ind[2]);
	check(resB, resC, 1, 2);
	check(resC, resB, 2, 1);
}

int main() {
	//clock_t start = clock();
	maxx = 0;
	scanf("%d %lld", &n, &k);
	for (i=0;i<n;i++) scanf("%d", &tab[i]);
	sort(tab, tab + n);
	//rozloz(k);
	sizA = sizB = sizC = 0;
	for (i=0;i<n;i++) {
		if (i % 6 == 0 || i % 6 == 5) tabA[sizA++] = tab[i];
		if (i % 6 == 1 || i % 6 == 4) tabB[sizB++] = tab[i];
		if (i % 6 == 2 || i % 6 == 3) tabC[sizC++] = tab[i];			
	}
	if (sizA > sizC) tabC[sizC++] = tabA[--sizA];
	k2 = (LL)pow(k, 1.0 / 2.0);
	if (k2 * k2 < k) k2++;
	k3 = pow(k, 1.0 / 3.0);
	if (k3 * k3 * k3 < k) k3++;
	
	for (i=0;i<3;i++) ind[i] = 0;
	go(1, tabA, 0, sizA, k, resA, 0);
	go(1, tabB, 0, sizB, k2, resB, 1);
	go(1, tabC, 0, sizC, k2, resC, 2);
	check();
	
	for (i=0;i<3;i++) ind[i] = 0;
	go(1, tabB, 0, sizB, k, resA, 0);
	go(1, tabA, 0, sizA, k2, resB, 1);
	go(1, tabC, 0, sizC, k2, resC, 2);
	check();
	
	for (i=0;i<3;i++) ind[i] = 0;
	go(1, tabC, 0, sizC, k, resA, 0);
	go(1, tabB, 0, sizB, k2, resB, 1);
	go(1, tabA, 0, sizA, k2, resC, 2);
	check();
	
	//printf("czas = %d\n", 1000 * (clock() - start) / CLOCKS_PER_SEC);
	printf("%lld\n", maxx);
}