結果

問題 No.3253 Banned Product
コンテスト
ユーザー vjudge1
提出日時 2026-11-22 13:29:17
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 4 ms / 2,000 ms
+ 886µs
コード長 876 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,568 ms
コンパイル使用メモリ 337,084 KB
実行使用メモリ 9,820 KB
最終ジャッジ日時 2026-11-22 13:29:21
合計ジャッジ時間 4,442 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

/* --- TYPEDEFS & MACROS --- */
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;


bool isPrime(long long x,int k) {
for (long long i = 2; i*i <= x; i++)
{
    if(x%i ==0) {
        int a = i;
        int b = x/a;
        if(a <=k && b <=k) return false;
    }
}
return true;
}



void solve() {
    ll n,k;
    cin >> n >> k;
    if(n==k) {
        cout << -1 << "\n";
        return ;
    }
    for (int i = n; i > k; i--)
    {
        if(isPrime(i,k)){
            cout << i << "\n";
            return;
        }
    }
    cout << -1 << "\n";
    
}

int main() {
    // Fast I/O
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t = 1;
    cin >> t; 
    while (t--) {
        solve();
    }

    return 0;
}
0