結果

問題 No.3253 Banned Product
ユーザー nonon
提出日時 2025-09-05 22:33:02
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 876 bytes
コンパイル時間 3,150 ms
コンパイル使用メモリ 275,740 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-09-05 22:33:33
合計ジャッジ時間 3,641 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

bool chmin(auto &a, auto b) { return a > b ? a = b, true : false; }
bool chmax(auto &a, auto b) { return a < b ? a = b, true : false; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T;
    cin >> T;
    while (T--) {
        int N, K;
        cin >> N >> K;
        auto check = [&] (int M) -> bool {
            for (int a = 1; a * a <= M; a++) {
                if (M % a == 0) {
                    int b = M / a;
                    if (a <= K && b <= K) return false;
                }
            }
            return true;
        };
        int M = max(1, N - 300);
        int ans = -1;
        while (N >= M) {
            if (check(N)) {
                ans = N;
                break;
            }
            N--;
        }
        cout << ans << '\n';
    }
}
0