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
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <cstdint>
using namespace std;

const long long thr = 1000000000ul;

const uint32_t tabsize = 1900000; //!!!!


int main() {
  long long k;
  int n,p;
  cin >> n >> k;

  
  vector<uint32_t> liczby;
  liczby.reserve(tabsize);
  liczby.push_back(1);
  liczby.push_back(thr+1);
   
  for(int i = 0; i < n; i++) {
    cin >> p;
    
    long long pi = p;
    if(pi == 2)
      pi = 8;
    while(pi < thr) {
      for(int j = 0; j < liczby.size(); j++) {
        if(liczby[j] * pi <= thr)
          liczby.push_back(liczby[j] * pi);
        else
          break;
      }
      pi *= p;
    }
    
    sort(liczby.begin(), liczby.end());
  }
  liczby.pop_back(); // remove thr

    
  long long best = 1;
  
  for(long long factor = 16; factor > 0; factor/=2) {
    auto reviter = liczby.end();
    for(auto iter = liczby.begin(); iter != liczby.end(); iter++) {
      while(reviter != liczby.begin() && factor * *iter * *(reviter-1) > k)
        reviter--;
      if(reviter == liczby.begin())
        break;
      long long candidate = factor * *iter * *(reviter-1);
      if(candidate > best)
        best = candidate;
    }
  }
  
  cout << best << endl;
  
  return 0;
}