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
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll N, k, ans=1, q = ((1ll)<<60); ll P[101];
ll mul(ll a, ll b)
{
    if(b==0)
        return 0;
    return (b%2==0) ? min((2*mul(a,b>>1)),q) : min((a+2*mul(a,b>>1)),q);
}
void solve(int i, ll cur)
{
    ans = max(ans,cur);
    if(i<k){
        while(cur<=N){
            solve(i+1,cur);
            cur = mul(cur,P[i]);
        }
    }
}
ll testcase_multiplication()
{
    sort(&P[0],&P[k]);
    solve(0,1);
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin >> k >> N;
    for(int i=0; i<k; i++)
        cin >> P[i];
    if(N==1)
        cout << "1\n";
    else
        cout << testcase_multiplication() <<"\n";
    return 0;
}