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
#include <algorithm>
#include <cstdio>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define INT(x) int x; scanf("%d", &x)
#define LLG(x) LL x; scanf("%lld", &x)

typedef long long LL;

int k, k1, k2;
LL n;
int p[30], p1[30], p2[30];
bool use[30];
LL mem[1010000];
int num;
LL res;

void go1(int i, LL x) {
	if (i == k1) {
		mem[num++] = x;
		return;
	}
	while (x <= n) {
		go1(i + 1, x);
		if (p1[i] > n / x) break;
		x *= p1[i];
	}
}

inline void check(LL x) {
	int b = upper_bound(mem, mem + num, n / x) - mem;
	res = max(res, x * mem[b - 1]);
}

void go2(int i, LL x) {
	if (i == k2) {
		check(x);
		return;
	}
	if (p2[i] == 2) {
		while (x <= n) {
			check(x);
			x <<= 1;
		}
	} else {
		while (x <= n) {
			go2(i + 1, x);
			if (p2[i] > n / x) break;
			x *= p2[i];
		}
	}
}

int main() {
	INT(k0);
	LLG(n0);
	k = k0;
	n = n0;
	REP(i,k) scanf("%d", &p[i]);
	sort(p, p + k);
	use[1] = use[2] = use[3] = use[4] = use[5] = use[8] = use[21] = use[22] = 1;
	REP(i,k) {
		if (use[i]) p1[k1++] = p[i];
		else p2[k2++] = p[i];
	}
	if (k2 > 1) rotate(p2, p2 + 1, p2 + k2);
	go1(0, 1);
	sort(mem, mem + num);
	go2(0, 1);
	printf("%lld\n", res);
}