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
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int p[25];
ll v[600];
int siz;
ll N;
ll ans;

inline ll trymul(ll k, ll x){
    if(N/k < x) return -1;
    k *= x;
    return k>N?-1:k;
}

void getmax(int idx, ll sofar){
    if(sofar>ans)
        ans=sofar;
    while(idx < siz){
        ll x = trymul(sofar, v[idx++]);
        if(x==-1) return;
        getmax(idx,x);
    }
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int k;
    cin>>k>>N;
    for(int i=0;i<k;++i) cin>>p[i];
    for(int i=0;i<k;++i)
        if(p[i] <= N)
            for(ll t=p[i];t!=-1;t=trymul(t,t))
                v[siz++] = t;
    sort(v,v+siz);
    getmax(0,1);
    cout<<ans<<'\n';
    return 0;
}