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
#include <stdio.h>

short int tab[101], k;
unsigned long long int n;

inline bool foo(unsigned long long int N){
	bool test = true;
	while(N != 1 && test != false){

		for(int i = 0; i < k; ++i){
			if(N % tab[i] == 0){
				N = N / tab[i];
				test = true;
				break;
			}
			test = false;	
		}
	}
	if(N == 1) return true;
	return false;
}
int main(){
	int i;
	scanf("%hd %lld", &k, &n);
	for(i = 0; i < k; ++i){
		scanf("%hd", &tab[i]);
	}
	for(long long j = n; j > 0; --j){
		if(foo(j)){
			printf("%lld", j);
			break;	
		}
	}
	return 0;
}