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
#include <cstdio>
#include <vector>

using namespace std;

typedef long long unsigned int LL;
typedef vector<long long> vLL;
typedef vector<long long>::iterator vLLi;
typedef vector<long long>::reverse_iterator vLLri;

int main()
{
LL K,N,k,tmp,N_min;
vLL P;

	scanf("%lld %lld",&K,&N);
	
	for (k = 0; k < K; k++)
	{
		scanf("%lld",&tmp);
		P.push_back(tmp);
	}

	N_min = 1;
	for (vLLi it = P.begin(); it != P.end(); ++it)
	{
		tmp = 1;
		while (tmp * (*it) < N) tmp *= (*it);
		if (N_min < tmp) N_min = tmp;
	}
	
//	printf("%lld\n",N_min);
	
	k = N_min;
	while (tmp+1 <= N)
	{
		k++;
//	printf("%lld\n",N);
		tmp = k;
		for (vLLi it = P.begin(); it != P.end(); ++it)
		{
			while ((tmp % *it) == 0) tmp /= *it;
		}
		if (tmp == 1) N_min = k;
	}

	printf("%lld\n",N_min);
	
	return 0;
}