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 <cstdio>
using namespace std;
typedef long long LL;

int k;
int p[100];

LL f(int, LL);

LL g(int mask0, int mask, int c, LL pr, LL N) {
    if(c == k) return pr*f(mask, N/pr);

    LL x = g(mask0, mask, c+1, pr, N);

    if(( mask0 & (1<<c) ) && pr <= N/p[c]) {
        LL y = g(mask0, mask | (1<<c), c+1, pr*p[c], N);
        if(x < y) x = y;
    }

    return x;
}


LL f(int mask, LL N) {
    if(mask == 0) return 1;
    return g(mask, 0, 0, 1, N);
}

int main() {
    LL N;
    scanf("%i %lli", &k, &N);
    for(int i = 0; i < k; i++)
        scanf("%i", p+i);
    printf("%lli", f((1<<k)-1, N));
}