D

首先暴力找出未出现的最小正整数。可以发现在数据取极限的情况下,这个数字最大是

观察可以得出,

也就是说,我们所需要额外添加的数字应该是在以内的质数相乘得到。

,想要增大答案,那么加入的数所包含的质数的幂次必须是大于对应的质数的幂次的。

于是预处理出每个质数的幂次 , (满足 并且 )。

然后跑dfs,每个质数选定一个幂次放入一个数组。最后判断,能否在次操作以内,每次操作从中选择若干个数字相乘(并且满足相乘后小于等于),并将这些数字从中删除。因为中的数字很少,每次贪心的从大往小选择即可。

由于,加个剪枝就能跑的很快。

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long 
#define endl '\n'

vector<int> P = { 2,3,5,7,11,13,17,19,23,29,31 };
const int inf = 1e18;
int mul(int x, int y) {
    __int128_t z = __int128_t(x) * y;
    if (z >= inf) return inf;
    return ll(z);
}

#ifdef LOCAL
template <class... Args> void debug(const Args&... args) { ((cerr << args << ", "), ...) << '\n'; }
#define debug(args...) cerr << #args << ": ", debug(args)
#define debugsq(x) cerr << #x << ": ["; for (auto i : x) cerr << i << ' '; cerr << "]\n";
#define debugmp(x) cerr << #x << ": [ "; for (auto [i, j] : x) cerr << '[' << i << "," << j << "] "; cerr << "]\n";
#else
#define debug(...) ;
#define debugsq(...) ;
#define debugmp(...) ;
#endif

void Prework() {

}
void Solve() {
    int n, x, y;cin >> n >> x >> y;
    //x = 1e14;
    //y = 1e14;
    //y = 72201776446800 - 1;
    //y = 2329089562800 - 1;
    //y = 80313433200 - 1;
    //y = 26771144400 - 1;
    //y = 5354228880 - 1;
    //y = 232792560 - 1;
    //y = 12252240 - 1;
    //y = 720720 - 1;
    //y = 360360 - 1;
    //y = 27720 - 1;
    //y = 2520 - 1;
    int l = 1, p = min(x, n);
    for (int i = 1;i <= x && i <= n;i++) {
        int nl = lcm(l, i);
        if (nl > y) {
            p = i - 1;
            break;
        }
        l = nl;
    }
    if (p == min(x, n)) {
        cout << l << endl;
        return;
    }
    vector<int> cnt(11);
    for (int i = 0;i < 11;i++) {
        int aux = l;
        while (aux % P[i] == 0) aux /= P[i], cnt[i]++;
    }
    vector<vector<array<int, 2>>> a(11);
    for (int i = 0;i < 11;i++) {
        int now = 1;
        for (int j = 1;j <= cnt[i];j++) now = mul(now, P[i]);
        int cur = 1;
        while (mul(now, P[i]) <= x && mul(mul(cur, P[i]), l) <= y) {
            now = mul(now, P[i]);
            cur = mul(cur, P[i]);
            a[i].push_back({ now,cur });
        }
    }
    vector<int> vec;
    int res = l;
    auto dfs = [&](auto&& dfs, array<int, 3> att, int t) {
        if (mul(att[1], l) > y) return;
        if (t == 11) {
            if (mul(att[1], l) <= res) return;
            auto V = vec;
            sort(V.begin(), V.end(), greater<int>());
            int k = 0;
            while (V.size()) {
                vector<int> nV;
                int now = 1, c = 0;
                for (int i = 0;i < V.size();i++) {
                    if (mul(now, V[i]) <= x) now = mul(now, V[i]);
                    else nV.push_back(V[i]);
                }
                swap(V, nV);
                k++;
            }
            //cout << att[1] << " " << l << endl;
            if (k + p <= n) res = max(res, mul(att[1], l));
            return;
        }
        dfs(dfs, att, t + 1);
        for (auto [u, v] : a[t]) {
            vec.push_back(u);
            array<int, 3> natt = { mul(att[0],u),mul(att[1],v),att[2] + 1 };
            dfs(dfs, natt, t + 1);
            vec.pop_back();
        }
        };
    dfs(dfs, { 1,1,0 }, 0);
    // cout << l << " " << p << endl;
    //cout << y / l << endl;
    // for (auto i : a) cout << i.size() << ' ';
    cout << res << endl;
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int T = 1;
    cin >> T;
    Prework();
    while (T--) Solve();
}