#include <stdint.h> #include <bits/stdc++.h> using namespace std; uint64_t div_by_2(uint64_t a) { return a / 2; } uint64_t div_by_3(uint64_t a) { return a / 3; } uint64_t div_by_5(uint64_t a) { return a / 5; } uint64_t div_by_7(uint64_t a) { return a / 7; } uint64_t div_by_11(uint64_t a) { return a / 11; } uint64_t div_by_13(uint64_t a) { return a / 13; } uint64_t div_by_17(uint64_t a) { return a / 17; } uint64_t div_by_19(uint64_t a) { return a / 19; } uint64_t div_by_23(uint64_t a) { return a / 23; } uint64_t div_by_29(uint64_t a) { return a / 29; } uint64_t div_by_31(uint64_t a) { return a / 31; } uint64_t div_by_37(uint64_t a) { return a / 37; } uint64_t div_by_41(uint64_t a) { return a / 41; } uint64_t div_by_43(uint64_t a) { return a / 43; } uint64_t div_by_47(uint64_t a) { return a / 47; } uint64_t div_by_53(uint64_t a) { return a / 53; } uint64_t div_by_59(uint64_t a) { return a / 59; } uint64_t div_by_61(uint64_t a) { return a / 61; } uint64_t div_by_67(uint64_t a) { return a / 67; } uint64_t div_by_71(uint64_t a) { return a / 71; } uint64_t div_by_73(uint64_t a) { return a / 73; } uint64_t div_by_79(uint64_t a) { return a / 79; } uint64_t div_by_83(uint64_t a) { return a / 83; } uint64_t div_by_89(uint64_t a) { return a / 89; } uint64_t div_by_97(uint64_t a) { return a / 97; } uint64_t (*div_by[])(uint64_t) = {NULL, NULL, div_by_2, div_by_3, NULL, div_by_5, NULL, div_by_7, NULL, NULL, NULL, div_by_11, NULL, div_by_13, NULL, NULL, NULL, div_by_17, NULL, div_by_19, NULL, NULL, NULL, div_by_23, NULL, NULL, NULL, NULL, NULL, div_by_29, NULL, div_by_31, NULL, NULL, NULL, NULL, NULL, div_by_37, NULL, NULL, NULL, div_by_41, NULL, div_by_43, NULL, NULL, NULL, div_by_47, NULL, NULL, NULL, NULL, NULL, div_by_53, NULL, NULL, NULL, NULL, NULL, div_by_59, NULL, div_by_61, NULL, NULL, NULL, NULL, NULL, div_by_67, NULL, NULL, NULL, div_by_71, NULL, div_by_73, NULL, NULL, NULL, NULL, NULL, div_by_79, NULL, NULL, NULL, div_by_83, NULL, NULL, NULL, NULL, NULL, div_by_89, NULL, NULL, NULL, NULL, NULL, NULL, NULL, div_by_97}; uint64_t dfs(uint64_t n, vector<int> const &p, uint64_t mul=1, int i0=0) { static uint64_t ans = 1; if(n * mul < ans) return 0; ans = max(ans, mul); if(n >= p[i0]) dfs(div_by[p[i0]](n), p, mul * p[i0], i0); if(i0 + 1 < p.size()) dfs(n, p, mul, i0 + 1); return ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int k; uint64_t n; cin >> k >> n; vector<int> p(k); for(int i = 0; i < k; i++) cin >> p[i]; sort(p.begin(), p.end(), std::greater<int>()); cout << dfs(n, p) << '\n'; return 0; }
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 | #include <stdint.h> #include <bits/stdc++.h> using namespace std; uint64_t div_by_2(uint64_t a) { return a / 2; } uint64_t div_by_3(uint64_t a) { return a / 3; } uint64_t div_by_5(uint64_t a) { return a / 5; } uint64_t div_by_7(uint64_t a) { return a / 7; } uint64_t div_by_11(uint64_t a) { return a / 11; } uint64_t div_by_13(uint64_t a) { return a / 13; } uint64_t div_by_17(uint64_t a) { return a / 17; } uint64_t div_by_19(uint64_t a) { return a / 19; } uint64_t div_by_23(uint64_t a) { return a / 23; } uint64_t div_by_29(uint64_t a) { return a / 29; } uint64_t div_by_31(uint64_t a) { return a / 31; } uint64_t div_by_37(uint64_t a) { return a / 37; } uint64_t div_by_41(uint64_t a) { return a / 41; } uint64_t div_by_43(uint64_t a) { return a / 43; } uint64_t div_by_47(uint64_t a) { return a / 47; } uint64_t div_by_53(uint64_t a) { return a / 53; } uint64_t div_by_59(uint64_t a) { return a / 59; } uint64_t div_by_61(uint64_t a) { return a / 61; } uint64_t div_by_67(uint64_t a) { return a / 67; } uint64_t div_by_71(uint64_t a) { return a / 71; } uint64_t div_by_73(uint64_t a) { return a / 73; } uint64_t div_by_79(uint64_t a) { return a / 79; } uint64_t div_by_83(uint64_t a) { return a / 83; } uint64_t div_by_89(uint64_t a) { return a / 89; } uint64_t div_by_97(uint64_t a) { return a / 97; } uint64_t (*div_by[])(uint64_t) = {NULL, NULL, div_by_2, div_by_3, NULL, div_by_5, NULL, div_by_7, NULL, NULL, NULL, div_by_11, NULL, div_by_13, NULL, NULL, NULL, div_by_17, NULL, div_by_19, NULL, NULL, NULL, div_by_23, NULL, NULL, NULL, NULL, NULL, div_by_29, NULL, div_by_31, NULL, NULL, NULL, NULL, NULL, div_by_37, NULL, NULL, NULL, div_by_41, NULL, div_by_43, NULL, NULL, NULL, div_by_47, NULL, NULL, NULL, NULL, NULL, div_by_53, NULL, NULL, NULL, NULL, NULL, div_by_59, NULL, div_by_61, NULL, NULL, NULL, NULL, NULL, div_by_67, NULL, NULL, NULL, div_by_71, NULL, div_by_73, NULL, NULL, NULL, NULL, NULL, div_by_79, NULL, NULL, NULL, div_by_83, NULL, NULL, NULL, NULL, NULL, div_by_89, NULL, NULL, NULL, NULL, NULL, NULL, NULL, div_by_97}; uint64_t dfs(uint64_t n, vector<int> const &p, uint64_t mul=1, int i0=0) { static uint64_t ans = 1; if(n * mul < ans) return 0; ans = max(ans, mul); if(n >= p[i0]) dfs(div_by[p[i0]](n), p, mul * p[i0], i0); if(i0 + 1 < p.size()) dfs(n, p, mul, i0 + 1); return ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int k; uint64_t n; cin >> k >> n; vector<int> p(k); for(int i = 0; i < k; i++) cin >> p[i]; sort(p.begin(), p.end(), std::greater<int>()); cout << dfs(n, p) << '\n'; return 0; } |