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
#include "stdio.h"
#include "stdlib.h"
 
#define LL	100
#define	PP	61
 
long long	 lp[LL][PP];
int			 pp[LL];
 
int			 k;
long long	 N, max;
 
void gen(long long n, int level)
{
	long long	 ml, nl;
	int			 i, l1;
 
	ml	= N / n;
	if (ml<lp[level][1])
		return;
 
	l1	= level + 1;
	i	= 0;
	while (i<pp[level] && lp[level][i] <= ml)
	{
		nl	= n * lp[level][i];
		if (nl > max)
			max	= nl;
 
		if (l1<k)
			gen(nl, l1);
 
		i++;
	}
}
 
int comparepint(const void *x, const void *y)
{
	return (*((int *) x) - *((int *) y));
}
 
 
int main()
{
	int			 i, j;
	long long	 pi, di;
 
	scanf("%d%lld", &k, &N);
	for (i=0; i<k; i++)
		scanf("%d", &pp[i]);
 
	qsort(pp, k, sizeof(int), comparepint);
 
	for (i=0; i<k; i++)
	{
		lp[i][0]	= 1;
		pi	= pp[i];
		di	= N / pi;
		j	= 0;
		while (lp[i][j]<=di)
		{
			lp[i][j+1]	= pi * lp[i][j];
			j++;
		}
		pp[i]	= ++j;
	}
 
	max	= 1;
	gen(1, 0);
 
	printf("%lld\n", max);
 
	return 0;
}