結果
| 問題 |
No.3253 Banned Product
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-09-05 21:51:12 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 7 ms / 2,000 ms |
| コード長 | 836 bytes |
| コンパイル時間 | 2,002 ms |
| コンパイル使用メモリ | 194,748 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-09-05 21:51:15 |
| 合計ジャッジ時間 | 2,646 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int T;
cin >> T;
while(T--){
int n, k;
cin >> n >> k;
// n -> k + 1までの素数
// k * k + 1以上の合成数
if(n > (ll)(k) * k){
cout << n << '\n';
continue;
}
int ans = -1;
while(n > k){
bool flg = true;
for(int i = 1; i * i <= n; i++){
if(n % i == 0){
if(n / i <= k){
flg = false;
break;
}
}
}
if(flg){
ans = n;
break;
}
n--;
}
cout << ans << '\n';
}
}