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
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#include<bits/stdc++.h>
#define ALL(X)        X.begin(),X.end()
#define FOR(I,A,B)    for(int (I) = (A); (I) <= (B); (I)++)
#define FORW(I,A,B)   for(int (I) = (A); (I) < (B);  (I)++)
#define FORD(I,A,B)   for(int (I) = (A); (I) >= (B); (I)--)
#define CLEAR(X)      memset(X,0,sizeof(X))
#define SIZE(X)       int(X.size())
#define CONTAINS(A,X) (A.find(X) != A.end())
#define PB            push_back
#define MP            make_pair
#define X             first
#define Y             second
using namespace std;
template<typename T, typename U> ostream& operator << (ostream& os, const pair<T, U> &_p) { return os << "(" << _p.X << "," << _p.Y << ")"; }
template<typename T> ostream& operator << (ostream &os, const vector<T>& _V) { bool f = true; os << "["; for(auto v: _V) { os << (f ? "" : ",") << v; f = false; } return os << "]"; }
template<typename T> ostream& operator << (ostream &os, const set<T>& _S) { bool f = true; os << "("; for(auto s: _S) { os << (f ? "" : ",") << s; f = false; } return os << ")"; }
template<typename T, typename U> ostream& operator << (ostream &os, const map<T, U>& _M) { return os << set<pair<T, U>>(ALL(_M)); }
typedef unsigned long long slong;
typedef long double ldouble;
typedef pair<int,int> pii;
const slong INF = 1000000100;
const ldouble EPS = 1e-9;

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<"="<<h<<","; _dbg(sdbg+1, a...);
}

#ifdef LOCALs
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

vector<slong> small, mid, big;
vector<slong> v, vmid, vbig;
slong N;

slong ans = 1;

inline int grt(slong a, slong b, slong c) {
    /// a * b > c ?
    if((64 - __builtin_clzll(a)) + (64 - __builtin_clzll(b)) > (65 - __builtin_clzll(c))) return 1;
    //if(double(a) * double(b) > 2.0 * double(c)) return 1;
    return (a * b > c);
}

const int MAXM = 100042;
int low[MAXM+42];

slong sum = 0, itcnt = 0, sums = 0;

void gen(vector<slong> &p, vector<slong> &vs, slong cur, int i, int s) {
    if(i >= SIZE(p)) return;
    slong tmp = 1;
    gen(p, vs, cur, i+1, s);
    while(42) {
        if(grt(cur * tmp, p[i], N)) break;
        tmp *= p[i];
        /// cur * tmp to osiagalna liczba
        slong x = cur * tmp;
        if(s) {
            if(x > 1) vs.PB(x);
            if(x <= N) ans = max(ans, x);
        }
        if(s != 1 && x <= N) { /// big or mid
            ans = max(ans, x);
            for(slong z : vmid) {
                if(grt(x, z, N)) break;
                slong xx = x * z;
                slong tg = 1;

                //tg = N / xx; /// wolno dziala :(
                int MAGIC = 3;
                if((xx << MAGIC) > N) {
                    while(xx * (tg + 1) <= N) tg++;
                    //sums++;
                }
                else tg = N / xx;

                slong y = xx;
                if(tg < MAXM) {
                    y *= low[tg];
                }
                else {
                    //sum++;
                    int st = 0, en = SIZE(v);
                    while(st + 1 < en) { /// xx * v[st] <= N
                        int shot = (st + en) / 2;
                        if(v[shot] > tg) en = shot;
                        else st = shot;
                        //itcnt++;
                    }
                    y *= v[st];
                }
                ans = max(ans, y);
            }
        }
        gen(p, vs, cur*tmp, i+1, s);
    }
}

void solve()
{
    const int A = 11, B = 42;
    slong k, n;
    cin >> k >> n;
    N = n;
    FOR(i,1,k) {
        int x;
        cin >> x;
        if(x <= A) small.PB(x);
        else if(x <= B) mid.PB(x);
        else big.PB(x);
    }

    v.reserve(300000);
    v.PB(1);
    vmid.reserve(200000);
    vmid.PB(1);
    vbig.PB(1);

    gen(small, v, 1, 0, 1);
    sort(ALL(v));

    for(slong x : v) {
        if(x < MAXM) low[x] = x;
    }
    FORW(i,1,MAXM) {
        if(!low[i]) low[i] = low[i-1];
    }

    gen(mid, vmid, 1, 0, 2);
    sort(ALL(vmid));

    gen(big, vbig, 1, 0, 0);

    //debug(SIZE(v), SIZE(vmid), SIZE(vbig));

    cout << ans << "\n";
    //debug(sums, sum,itcnt,itcnt/max(slong(1),sum));
    //cin >> ans[0];
}

int main()
{
    ios_base::sync_with_stdio(0);
    solve();
}