結果

問題 No.3253 Banned Product
コンテスト
ユーザー vjudge1
提出日時 2026-11-22 13:17:46
言語 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
結果
WA  
実行時間 -
コード長 1,144 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,325 ms
コンパイル使用メモリ 334,552 KB
実行使用メモリ 9,928 KB
最終ジャッジ日時 2026-11-22 13:17:50
合計ジャッジ時間 3,772 ms
ジャッジサーバーID
(参考情報)
judge6_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 2 WA * 7
権限があれば一括ダウンロードができます

ソースコード

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>;

#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define sz(x) static_cast<int>((x).size())
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define rrep(i, a, b) for (int i = (a); i >= (b); --i)

/* --- CONSTANTS --- */
const int INF = 1e9 + 7;
const ll LINF = 1e18 + 9;
const int MOD = 1e9 + 7; // 998244353


bool isPrime(long long x) {
for (long long i = 2; i*i <= x; i++)
{
    if(x%i ==0)return false;
}
return true;
}



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