結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
// #include<atcoder/all>
// using mint = atcoder::modint998244353;
using ld = long double;
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(int)(n);++i)
template<typename T>bool chmin(T&a,T b){return b<a?(a=b,1):0;}
template<typename T>bool chmax(T&a,T b){return b>a?(a=b,1):0;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int T;
    cin>>T;
    while(T--){
        long N,K;
        cin>>N>>K;

        for(long i=N;i>=K;i--){
            if(i==K){
                cout<<-1<<"\n";
                break;
            }
            bool b=1;
            for(long j=max(2l, (i+K-1)/K);j*j<=i&&j<=K;j++){
                if(i%j==0) {
                    b=0;
                    break;
                }
            }
            if(b){
                cout<<i<<"\n";
                break;
            }
        }
    }
}
0