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

#define ILO_ENABLED

using namespace std;

static const long long N = 1E18;
static const int K = 25;

static int p[K + 1];

long long product(const int* p, const long long n)
{
    long long m = 1;

    while(*p)
    {
        const long long r = n / *p;
        m = max(m, *p*(r > 1 ? product(p, r) : r));
        p++;
    }

    return m;
}

#ifdef ILO_ENABLED
int main()
{
    int k;
    long long n;

    while(scanf("%d%lld", &k, &n) > 0)
    {
        for(int i = 0; i < k; i++)
        {
            scanf("%d", p + i);
        }

        sort(p, p + k);
        p[k] = 0;

        printf("%lld\n", product(p, n));
    }

    return 0;
}
#endif