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 <iostream>
#include <vector>

using namespace std;

bool is_multi(vector<int> *primary, uint64_t val) {
    while (val!=1) {
        bool used = false;
        for (uint64_t count = 0; count < (*primary).size(); count++){
            if(val%(*primary)[count]==0){
                val = val/(*primary)[count];
                //cout << val <<'\n';
                used = true;
            }
        }
        if(!used){
            return false;
        }
    }
    return true;
}

int main() {
    uint64_t k, n;
    cin >> k >> n;
    vector<int> primary;
    for (int count = 0; count < k; count++) {
        int temp;
        cin >> temp;
        primary.push_back(temp);
    }
    uint64_t out = 0;
    for (uint64_t count = n; count > 0; count--) {
        if (is_multi(&primary, count)) {
            out = count;
            break;
        }
    }
    cout << out << '\n';
    return 0;
}