結果

問題 No.3253 Banned Product
コンテスト
ユーザー Muhammad Ashar Usmani
提出日時 2025-11-16 22:04:56
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 717 bytes
コンパイル時間 1,873 ms
コンパイル使用メモリ 196,284 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-11-16 22:04:59
合計ジャッジ時間 2,355 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

// asharusmani
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T;
    if(!(cin>>T)) return 0;
    while(T--){
        ll N,K; cin>>N>>K;
        if(N > K*K){
            cout<<N<<"\n";
            continue;
        }
        ll ans = -1;
        for(ll x = N; x > K; --x){
            bool ok = true;
            ll r = floor(sqrt((long double)x));
            for(ll d = 1; d <= r; ++d){
                if(x % d) continue;
                ll e = x/d;
                if(d <= K && e <= K){ ok = false; break; }
            }
            if(ok){ ans = x; break; }
        }
        cout<<ans<<"\n";
    }
    return 0;
}
0